You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
misskey_bot/main.py

56 lines
1.3 KiB
Python

#!/usr/bin/python3
import requests
import json
import time
def json_read(file):
with open(file) as f:
config = json.load(f)
return config
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)
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'])