|
|
|
@ -12,8 +12,10 @@ def json_read(file):
|
|
|
|
|
config = json.load(f)
|
|
|
|
|
return config
|
|
|
|
|
|
|
|
|
|
# Temp
|
|
|
|
|
config = json_read('config.json')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#try:
|
|
|
|
|
# config = json_read('config.json')
|
|
|
|
|
#except FileNotFoundError:
|
|
|
|
@ -26,38 +28,36 @@ if config['verbosity'].upper() == 'DEBUG':
|
|
|
|
|
|
|
|
|
|
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']
|
|
|
|
|
#msk.notes_create(text="Wannya see my picture?", cw="Nya?", fileIds=[fid])
|
|
|
|
|
async def main():
|
|
|
|
|
log.info("Connecting to {}".format(msk.url))
|
|
|
|
|
async with websockets.connect(msk.ws_url) as ws:
|
|
|
|
|
print('Connecting')
|
|
|
|
|
log.info('Sucessfully connected to {}'.format(msk.url))
|
|
|
|
|
log.info('Attemping to watch timeline')
|
|
|
|
|
p = {
|
|
|
|
|
'type': 'connect',
|
|
|
|
|
'body': {
|
|
|
|
|
'channel': 'homeTimeline',
|
|
|
|
|
'id': 'Nya1'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
await ws.send(json.dumps(p))
|
|
|
|
|
p = {
|
|
|
|
|
'type': 'connect',
|
|
|
|
|
'body': {
|
|
|
|
|
'channel': 'main',
|
|
|
|
|
'id': 'Nya2'
|
|
|
|
|
'channel': 'main'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
await ws.send(json.dumps(p))
|
|
|
|
|
|
|
|
|
|
print('Listening')
|
|
|
|
|
log.info('Listening to timeline')
|
|
|
|
|
while True:
|
|
|
|
|
data = await ws.recv()
|
|
|
|
|
j = json.loads(data)
|
|
|
|
|
if j['type'] == 'channel':
|
|
|
|
|
if j['body']['type'] == 'followed':
|
|
|
|
|
print("Follow!")
|
|
|
|
|
msk.following_create(j['body']['body']['id'])
|
|
|
|
|
if j['body']['type'] == 'mention':
|
|
|
|
|
if not j['body']['body']['replyId']:
|
|
|
|
|
msk.notes_create(renoteId=j['body']['body']['id'])
|
|
|
|
|
print(j)
|
|
|
|
|
|
|
|
|
|
while True:
|
|
|
|
|
try:
|
|
|
|
|
asyncio.get_event_loop().run_until_complete(main())
|
|
|
|
|
loop = asyncio.new_event_loop()
|
|
|
|
|
#asyncio.set_event_loop(loop)
|
|
|
|
|
loop.run_until_complete(main())
|
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|