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