diff --git a/main.py b/main.py index 64a7637..18b8ba6 100644 --- a/main.py +++ b/main.py @@ -45,7 +45,7 @@ def get_notifications(url, i): # Функция, создающая пост # 2do: посты с картинками, ... -def create_post(content, url, i, visibility="public", channel="", fileIds=[]): +def create_post(content, url, i, visibility="public", channel=""): print("Post to", url, ":", content) # Аналогично, адрес нужной функции API req_url = url + "/api/notes/create" @@ -56,7 +56,6 @@ def create_post(content, url, i, visibility="public", channel="", fileIds=[]): "noExtractEmojis": True, "visibility": visibility, "text": content, - "fileIds": fileIds, # Если поставлен канал, то пост только локальный для инстанса "localOnly": channel != "", "i": i @@ -69,37 +68,9 @@ def create_post(content, url, i, visibility="public", channel="", fileIds=[]): if r.status_code == 200: return 0 else: - print("Failed to post:", r.text) + print("Failed to post:", result.json()['error']['message']) return 1 -# Пока что можешь не пытаться разобраться, я сам отчасти хз, как это работает, лол - -def file_upload(file, url, i, isSensitive=False): - print("Uploading file to", url) - req_url = url + "/api/drive/files/create" - with open(file, "rb") as f: - fileo = f.read() - body = { - "isSensitive": False, - "force": True, - "i":i - } - body = json.dumps(body) - - payload = {'json_payload': body, 'i': i } - - files = {"file": (file, fileo)} - r = requests.post(req_url, data=payload, files=files) - if r.status_code == 200: - return r.json() - else: - print("Upload failed with code", r.status_code) - print(r.text) - -def get_file_list(url, i): - req_url = url + "/api/drive/files" - r = requests.post(req_url, json={"i":i}) - print(r.json()) ### Сюда надо захуярить еще 100500 функций### # Собсна, содержательная часть программы начинается тут @@ -107,10 +78,5 @@ def get_file_list(url, i): # Читаем конфиг, получаем словарь config = json_read('config.json') -#notif_list = get_notifications(config['url'], config['token']) -#print(notif_list) -#file_upload('test.jpg', config['url'], config['token']) -im_info = file_upload('test.jpg', config['url'], config['token']) - -create_post("Nya~", config['url'], config['token'], fileIds=[im_info['id']]) +notif_list = get_notifications(config['url'], config['token']) #print(notif_list)