From f14dc1f239f1f073f72472ceaaa9284382e50c6f Mon Sep 17 00:00:00 2001 From: Finn Christiansen Date: Wed, 12 Jun 2024 22:27:41 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Add=20return=20types?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- matrix_bot_praying_times/__main__.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/matrix_bot_praying_times/__main__.py b/matrix_bot_praying_times/__main__.py index 42ea33a..276f707 100644 --- a/matrix_bot_praying_times/__main__.py +++ b/matrix_bot_praying_times/__main__.py @@ -3,6 +3,7 @@ import requests import datetime import asyncio import pytz +from typing import Dict import os from dotenv import load_dotenv @@ -24,7 +25,7 @@ user_room_ids: dict = {} @bot.listener.on_message_event -async def echo(room, message): +async def echo(room, message) -> None: match = botlib.MessageMatch(room, message, bot, PREFIX) if match.is_not_from_this_bot() and match.prefix() and match.command("echo"): @@ -35,7 +36,7 @@ async def echo(room, message): @bot.listener.on_message_event -async def times(room, message): +async def times(room, message) -> None: match = botlib.MessageMatch(room, message, bot, PREFIX) username = str(message).split(': ')[0] response = "" @@ -53,7 +54,7 @@ async def times(room, message): @bot.listener.on_message_event -async def usage(room, message): +async def usage(room, message) -> None: match = botlib.MessageMatch(room, message, bot, PREFIX) response = """usage: @@ -67,7 +68,7 @@ async def usage(room, message): @bot.listener.on_message_event -async def set_location(room, message): +async def set_location(room, message) -> None: match = botlib.MessageMatch(room, message, bot, PREFIX) response = "" @@ -81,7 +82,7 @@ async def set_location(room, message): @bot.listener.on_message_event -async def set_reminder(room, message): +async def set_reminder(room, message) -> None: match = botlib.MessageMatch(room, message, bot, PREFIX) response = "" @@ -101,7 +102,7 @@ async def set_reminder(room, message): await bot.api.send_markdown_message(room.room_id, response) -def get_praying_times(date: datetime.date, username): +def get_praying_times(date: datetime.date, username) -> Dict[str, str]: day = date.day month = date.month year = date.year @@ -111,7 +112,7 @@ def get_praying_times(date: datetime.date, username): return times -def schedule_reminder(username): +def schedule_reminder(username) -> None: # TODO: add peristence for reminders times = get_praying_times(datetime.date.today(), username) now = datetime.datetime.now(datetime.UTC) @@ -123,7 +124,7 @@ def schedule_reminder(username): asyncio.ensure_future(remind(username, message, seconds - user_reminders[username] * 60)) -async def remind(username, message, seconds): +async def remind(username, message, seconds) -> None: await asyncio.sleep(seconds) await bot.api.send_markdown_message(user_room_ids[username], message)