diff --git a/classes/pyroclient.py b/classes/pyroclient.py index 118654a..ff83727 100644 --- a/classes/pyroclient.py +++ b/classes/pyroclient.py @@ -19,11 +19,11 @@ logger = logging.getLogger(__name__) class PyroClient(LibPyroClient): def __init__(self, **kwargs): - self.__version__ = (0, 1, 2) + self.__version__ = (0, 1, 3) super().__init__(**kwargs) - self.updater = Updater(ClientSession()) + self.updater = Updater() self.contexts = [] if self.scheduler is not None: diff --git a/classes/updater.py b/classes/updater.py index 0f06c59..d1a2930 100644 --- a/classes/updater.py +++ b/classes/updater.py @@ -1,5 +1,5 @@ import logging -from typing import Any, Dict, Tuple +from typing import Any, Dict, Tuple, Union from aiohttp import ClientSession @@ -7,12 +7,15 @@ logger = logging.getLogger(__name__) class Updater: - def __init__(self, client_session: ClientSession) -> None: - self.client_session: ClientSession = client_session + def __init__(self, client_session: Union[ClientSession, None] = None) -> None: + self.client_session: Union[ClientSession, None] = client_session async def check_updates( self, version_current: Tuple[int, int, int], api_url: str ) -> bool: + if not self.client_session: + self.client_session = ClientSession() + response = await self.client_session.get(api_url) if response.status != 200: @@ -30,6 +33,9 @@ class Updater: ) async def get_latest_release(self, api_url: str) -> Dict[str, Any]: + if not self.client_session: + self.client_session = ClientSession() + response = await self.client_session.get(api_url) if response.status != 200: diff --git a/locale/de.json b/locale/de.json index 05115c7..732e457 100644 --- a/locale/de.json +++ b/locale/de.json @@ -8,7 +8,7 @@ }, "bot": { "name": "Garbage Reminder", - "about": "Nie wieder Müllabfuhrtermin verpassen. Quellcode: https://garbagebot.eu", + "about": "Nie wieder Müllabfuhrtermin verpassen. Mehr erfahren: https://garbagebot.eu", "description": "Sie können Erinnerungen an die Müllabfuhr für Orte Ihrer Wahl erhalten.\n\nVerwenden Sie /help, um die Funktionsweise des Bots besser zu verstehen, oder verwenden Sie /setup, um Ihre Erinnerungen zu konfigurieren." }, "formats": { @@ -100,4 +100,4 @@ "callbacks": { "locale_set": "Ihre Sprache ist jetzt: {locale}" } -} +} \ No newline at end of file diff --git a/locale/en.json b/locale/en.json index f4df4b6..4a662ec 100644 --- a/locale/en.json +++ b/locale/en.json @@ -8,7 +8,7 @@ }, "bot": { "name": "Garbage Reminder", - "about": "Never forget about garbage collection again. Source code: https://garbagebot.eu", + "about": "Never forget about garbage collection again. Learn more: https://garbagebot.eu", "description": "You can receive reminders about garbage collection for locations of your choice.\n\nUse /help to better understand how the bot works or use /setup to configure your reminders." }, "formats": { diff --git a/locale/ru.json b/locale/ru.json index 2d14cff..5d995bb 100644 --- a/locale/ru.json +++ b/locale/ru.json @@ -8,7 +8,7 @@ }, "bot": { "name": "Garbage Reminder 🇺🇦", - "about": "Більше ніколи не забувайте про вивезення сміття. Вихідний код: https://garbagebot.eu", + "about": "Більше ніколи не забувайте про вивезення сміття. Дізнатись більше: https://garbagebot.eu", "description": "Ви можете отримувати нагадування про вивезення сміття для обраних вами місць.\n\nВикористовуйте /help, щоб краще зрозуміти, як працює бот, або /setup, щоб налаштувати нагадування." }, "formats": { @@ -100,4 +100,4 @@ "set_offset": "Кількість днів", "set_time": "Час у вигляді ГГ:ХХ" } -} +} \ No newline at end of file diff --git a/locale/uk.json b/locale/uk.json index 513e748..bc52920 100644 --- a/locale/uk.json +++ b/locale/uk.json @@ -8,7 +8,7 @@ }, "bot": { "name": "Garbage Reminder 🇺🇦", - "about": "Більше ніколи не забувайте про вивезення сміття. Вихідний код: https://garbagebot.eu", + "about": "Більше ніколи не забувайте про вивезення сміття. Дізнатись більше: https://garbagebot.eu", "description": "Ви можете отримувати нагадування про вивезення сміття для обраних вами місць.\n\nВикористовуйте /help, щоб краще зрозуміти, як працює бот, або /setup, щоб налаштувати нагадування." }, "formats": { @@ -100,4 +100,4 @@ "set_offset": "Кількість днів", "set_time": "Час у вигляді ГГ:ХХ" } -} +} \ No newline at end of file diff --git a/main.py b/main.py index 2cb0e19..7818ff9 100644 --- a/main.py +++ b/main.py @@ -4,6 +4,7 @@ from argparse import ArgumentParser from os import getpid from pathlib import Path +from aiohttp import ClientSession from convopyro import Conversation from libbot import sync @@ -41,7 +42,8 @@ def main(): exit() client = PyroClient( - scheduler=scheduler, commands_source=sync.json_read(Path("commands.json")) + scheduler=scheduler, + commands_source=sync.json_read(Path("commands.json")), ) Conversation(client) diff --git a/plugins/commands/toggle.py b/plugins/commands/toggle.py index c19e232..7531083 100644 --- a/plugins/commands/toggle.py +++ b/plugins/commands/toggle.py @@ -13,7 +13,7 @@ async def command_toggle(app: PyroClient, message: Message): await user.update_state(not user.enabled) - if user.enabled: + if not user.enabled: await message.reply_text( app._("toggle_disabled", "messages", locale=user.locale) ) diff --git a/requirements.txt b/requirements.txt index 6ecfc8a..a43cab0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,12 +1,12 @@ -aiohttp~=3.9.5 +aiohttp~=3.10.2 apscheduler~=3.10.4 +async_pymongo==0.1.9 convopyro==0.5 mongodb-migrations==1.3.1 pytz>=2024.1 tgcrypto==1.2.5 ujson>=5.0.0 -uvloop==0.19.0 +uvloop==0.20.0 --extra-index-url https://git.end-play.xyz/api/packages/profitroll/pypi/simple -async_pymongo==0.1.4 -libbot[speed,pyrogram]==3.2.2 +libbot[speed,pyrogram]==3.2.3 pykeyboard==0.1.7 \ No newline at end of file