add some debug output

master
lub 4 years ago
parent 6e9823df5e
commit 54a0261cae

@ -119,9 +119,10 @@ async def main():
while True:
# do sync first to e.g. accept an admin room invite
sync = await matrix.sync(timeout=30000, sync_filter=sync_filter)
print('last sync: '+datetime.now())
print('last sync: '+str(datetime.now()))
for room_id in sync.rooms.invite:
print('joining '+room_id)
print('joining: '+room_id)
await matrix.join(room_id)
if next_update < datetime.now():
@ -132,6 +133,7 @@ async def main():
if hasattr(cache_state, 'content') and 'url_list' in cache_state.content:
cache = cache_state.content['url_list']
else:
print('cache is empty')
cache = []
# scape all blog posts and process them
@ -141,6 +143,8 @@ async def main():
if post['url'] not in cache and post['category'] == category:
# post url not found in cache
# announce new post to matrix rooms
print('new post: '+post['url'])
content = {
'msgtype': 'm.notice',
'body': get_body(post),
@ -150,6 +154,7 @@ async def main():
for room_id in matrix.rooms:
# don't send updates to the admin room
if room_id != admin_room:
print('to room: '+room_id)
await matrix.room_send(room_id=room_id,
message_type='m.room.message',
content=content)
@ -175,13 +180,23 @@ async def main():
# wait between 15min and 30min to randomize scraping
next_update = datetime.now() + timedelta(minutes=randrange(15, 30))
print('next scrape: '+str(next_update))
homeserver = environ['HOMESERVER']
print('homeserver: '+homeserver)
mxid = environ['MXID']
print('homeserver: '+mxid)
accesstoken = get_accesstoken_from_file(environ['ACCESSTOKEN_FILE'])
print('accesstoken_file: '+environ['ACCESSTOKEN_FILE'])
admin_room = environ['ADMIN_ROOM']
print('admin_room: '+admin_room)
category = environ['CATEGORY']
print('category: '+category)
asyncio.run(main())

Loading…
Cancel
Save