This commit is contained in:
Moe Poi ~ 2022-11-24 13:54:15 +07:00
parent bd48d830e2
commit 538c8019b3
Signed by: moepoi
GPG key ID: 334B501E883409AF
2 changed files with 1 additions and 26 deletions

View file

@ -1,6 +1,4 @@
from python_graphql_client import GraphqlClient
import requests
import json
import pathlib
import re
import os
@ -257,33 +255,11 @@ def fetch_activity(oauth_token, userId):
pass
return results
def share_activity(token, text, visibility):
try:
url = "https://moe.onl/api/notes/create"
payload = json.dumps({
"i": token,
"text": text,
"visibility": visibility
})
headers = {
'Content-Type': 'application/json'
}
requests.request("POST", url, headers=headers, data=payload)
except Exception as e:
print (e)
if __name__ == "__main__":
readme = root / "README.md"
readme_contents = readme.open().read()
# List Activity
data = fetch_activity(TOKEN, userId=161753)
if data[0]['progress'] != None:
share_text = f"{data[0]['status']} {data[0]['progress']} of [{data[0]['title']}]({data[0]['url']})"
else:
share_text = f"{data[0]['status']} [{data[0]['title']}]({data[0]['url']})"
share_activity(SHARE_TOKEN, share_text, "public")
res = "\n".join(
[
"* [{status} {progress}]({activity_url}) of [{title}]({url})".format(**x)

View file

@ -1,2 +1 @@
python-graphql-client==0.3.0
requests
python-graphql-client==0.3.0