new file: .gitignore

new file:   config.json.example
	modified:   main.py
pull/1/head
nihonium 3 years ago
parent b38c14a16f
commit 1001e3887f

1
.gitignore vendored

@ -0,0 +1 @@
config.json

@ -0,0 +1,7 @@
{
"nyan.nekoea.red": {
"name": "nyan.nekoea.red",
"url" : "https://nyan.nekoea.red",
"token": "nyanyanyanyanyanyanya",
},
}

@ -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
if __name__ == '__main__':
pass
config = json_read("config.json")
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'])

Loading…
Cancel
Save