fix sync and task reminder
This commit is contained in:
@@ -5,6 +5,7 @@ import threading
|
||||
import sys
|
||||
from time import sleep
|
||||
import datetime
|
||||
import requests
|
||||
|
||||
from aiohttp import ClientConnectionError, ServerDisconnectedError
|
||||
from nio import (
|
||||
@@ -56,15 +57,18 @@ def is_time_between(begin_time, end_time, check_time=None):
|
||||
async def foo(client):
|
||||
ShouldSendReminder = True
|
||||
while True:
|
||||
print(datetime.today().weekday())
|
||||
await client.sync()
|
||||
if is_time_between(time(10,00), time(11,10)):
|
||||
if is_time_between(time(9,00), time(10,10)):
|
||||
print("Ist Time to check")
|
||||
if ShouldSendReminder:
|
||||
handler = CaldavHandler()
|
||||
messages = handler.send_reminders()
|
||||
for message in messages:
|
||||
await send_text_to_room(client, "!aRFGSGKGeaBxiEfDMC:matrix.org", message)
|
||||
|
||||
if datetime.datetime.today().weekday() == 1: #check if its tuesday
|
||||
print("Check if its tuesday")
|
||||
if datetime.today().weekday() == 1: #check if its tuesday
|
||||
await send_text_to_room(client, "!aRFGSGKGeaBxiEfDMC:matrix.org", weekly_task_reminder())
|
||||
|
||||
ShouldSendReminder = False
|
||||
@@ -154,20 +158,20 @@ async def main():
|
||||
|
||||
#logger.info(f"Logged in as {config.user_id}")
|
||||
await client.join("!aRFGSGKGeaBxiEfDMC:matrix.org")
|
||||
#print("joined room")
|
||||
#sleep(5)
|
||||
#await client.sync()
|
||||
#print(client.rooms)
|
||||
print("joined room")
|
||||
sleep(5)
|
||||
await client.sync(full_state=True)
|
||||
print(client.rooms)
|
||||
|
||||
##await client.room_send(
|
||||
## # Watch out! If you join an old room you'll see lots of old messages
|
||||
## room_id="!zKwFlsxXpmVhBMdOBa:matrix.org",
|
||||
## message_type="m.room.message",
|
||||
## content={"msgtype": "m.text", "body": "Hello world!"},
|
||||
## )
|
||||
##t = threading.Thread(target = foo, args =(client, ))
|
||||
##t.start()
|
||||
#await foo(client)
|
||||
#await client.room_send(
|
||||
# # Watch out! If you join an old room you'll see lots of old messages
|
||||
# room_id="!zKwFlsxXpmVhBMdOBa:matrix.org",
|
||||
# message_type="m.room.message",
|
||||
# content={"msgtype": "m.text", "body": "Hello world!"},
|
||||
# )
|
||||
#t = threading.Thread(target = foo, args =(client, ))
|
||||
#t.start()
|
||||
await foo(client)
|
||||
await client.sync_forever(timeout=30000, full_state=True)
|
||||
|
||||
except (ClientConnectionError, ServerDisconnectedError):
|
||||
|
||||
Reference in New Issue
Block a user