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