|
|
|
#!/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'])
|