|
|
@ -3,6 +3,8 @@ import logging as log
|
|
|
|
import requests
|
|
|
|
import requests
|
|
|
|
import json
|
|
|
|
import json
|
|
|
|
import msk
|
|
|
|
import msk
|
|
|
|
|
|
|
|
import websockets
|
|
|
|
|
|
|
|
import asyncio, aiohttp
|
|
|
|
|
|
|
|
|
|
|
|
def json_read(file):
|
|
|
|
def json_read(file):
|
|
|
|
print("Reading config file: {}".format(file))
|
|
|
|
print("Reading config file: {}".format(file))
|
|
|
@ -12,6 +14,12 @@ def json_read(file):
|
|
|
|
|
|
|
|
|
|
|
|
config = json_read('config.json')
|
|
|
|
config = json_read('config.json')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#try:
|
|
|
|
|
|
|
|
# config = json_read('config.json')
|
|
|
|
|
|
|
|
#except FileNotFoundError:
|
|
|
|
|
|
|
|
# print("Config file not found. Maybe we should launch setup.py?")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if config['verbosity'].upper() == 'DEBUG':
|
|
|
|
if config['verbosity'].upper() == 'DEBUG':
|
|
|
|
log.basicConfig(format="%(levelname)s: %(message)s", level=log.DEBUG)
|
|
|
|
log.basicConfig(format="%(levelname)s: %(message)s", level=log.DEBUG)
|
|
|
|
log.info("Verbose output")
|
|
|
|
log.info("Verbose output")
|
|
|
@ -19,6 +27,37 @@ if config['verbosity'].upper() == 'DEBUG':
|
|
|
|
msk = msk.Misskey(i=config['token'], url=config['url'])
|
|
|
|
msk = msk.Misskey(i=config['token'], url=config['url'])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fid = msk.drive_files_create("yaoshi-jun-Toosaka-Rin-Fate-(series)-Anime-3306019.jpeg", isSensitive=True)['id']
|
|
|
|
#fid = msk.drive_files_create("yaoshi-jun-Toosaka-Rin-Fate-(series)-Anime-3306019.jpeg", isSensitive=True)['id']
|
|
|
|
msk.notes_create(text="Wannya see my picture?", cw="Nya?", fileIds=[fid])
|
|
|
|
#msk.notes_create(text="Wannya see my picture?", cw="Nya?", fileIds=[fid])
|
|
|
|
|
|
|
|
async def main():
|
|
|
|
|
|
|
|
async with websockets.connect(msk.ws_url) as ws:
|
|
|
|
|
|
|
|
print('Connecting')
|
|
|
|
|
|
|
|
p = {
|
|
|
|
|
|
|
|
'type': 'connect',
|
|
|
|
|
|
|
|
'body': {
|
|
|
|
|
|
|
|
'channel': 'homeTimeline',
|
|
|
|
|
|
|
|
'id': 'Nya1'
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
await ws.send(json.dumps(p))
|
|
|
|
|
|
|
|
p = {
|
|
|
|
|
|
|
|
'type': 'connect',
|
|
|
|
|
|
|
|
'body': {
|
|
|
|
|
|
|
|
'channel': 'main',
|
|
|
|
|
|
|
|
'id': 'Nya2'
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
await ws.send(json.dumps(p))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print('Listening')
|
|
|
|
|
|
|
|
while True:
|
|
|
|
|
|
|
|
data = await ws.recv()
|
|
|
|
|
|
|
|
j = json.loads(data)
|
|
|
|
|
|
|
|
print(j)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while True:
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
asyncio.get_event_loop().run_until_complete(main())
|
|
|
|
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
|
|