niho #1
					 3 changed files with 53 additions and 11 deletions
				
			
		
							
								
								
									
										1
									
								
								.gitignore
									
										
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
										
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1 @@ | |||
| config.json | ||||
							
								
								
									
										7
									
								
								config.json.example
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								config.json.example
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,7 @@ | |||
| { | ||||
|   "nyan.nekoea.red": { | ||||
|     "name": "nyan.nekoea.red", | ||||
|     "url" : "https://nyan.nekoea.red", | ||||
|     "token": "nyanyanyanyanyanyanya", | ||||
|   }, | ||||
| } | ||||
							
								
								
									
										56
									
								
								main.py
									
										
									
									
									
								
							
							
						
						
									
										56
									
								
								main.py
									
										
									
									
									
								
							|  | @ -1,21 +1,55 @@ | |||
| #!/usr/bin/python3 | ||||
| 
 | ||||
| import requests | ||||
| import re | ||||
| import json | ||||
| 
 | ||||
| def img_upload(): | ||||
|     pass | ||||
| 
 | ||||
| def create_post(): | ||||
|     pass | ||||
| import time | ||||
| 
 | ||||
| def json_read(file): | ||||
|     pass | ||||
|     with open(file) as f: | ||||
|         config = json.load(f) | ||||
|     return config | ||||
| 
 | ||||
| if __name__ == '__main__': | ||||
|     pass | ||||
| def get_notifications(url, i): | ||||
|     print("Getting notifications from", url) | ||||
|     req_url = url + "/api/i/notifications" | ||||
|     print(req_url) | ||||
|     body = { | ||||
|             "i": i, | ||||
|             #"includeTypes": [ | ||||
|             #        "reply", | ||||
|             #        "mention" | ||||
|             #        ], | ||||
|             "limit": 3, | ||||
|             "unreadOnly": True, | ||||
|     } | ||||
|     r = requests.post(req_url, json=body) | ||||
|      | ||||
|     config = json_read("config.json") | ||||
|     if r.status_code == 200: | ||||
|         print(r.json()) | ||||
|     else: | ||||
|         print("Fuck") | ||||
| 
 | ||||
| def create_post(content, url, i, visibility="public", channel=""): | ||||
|     print("Post to", url, ":", content) | ||||
|     req_url = url + "/api/notes/create" | ||||
|     body = { | ||||
|             "noExtractMentions": True, | ||||
|             "noExtractHashtags": True, | ||||
|             "noExtractEmojis": True, | ||||
|             "visibility": visibility, | ||||
|             "text": content, | ||||
|             "localOnly": channel != "", | ||||
|             "i": i | ||||
|     } | ||||
|     if channel != "": | ||||
|         body["channelId"] = channel | ||||
|     r = requests.post(req_url, json=body) | ||||
|     if r.status_code == 200: | ||||
|         return 0 | ||||
|     else: | ||||
|         print("Failed to post:", result.json()['error']['message']) | ||||
|         return 1 | ||||
| 
 | ||||
| config = json_read('config.json') | ||||
| 
 | ||||
| get_notifications(config['url'], config['token']) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue