From 11381ce9702a09694c55d5013a93649a7521fb01 Mon Sep 17 00:00:00 2001 From: bbralyc Date: Fri, 29 Sep 2023 17:51:45 +0400 Subject: [PATCH] updated readme.md && requirements.txt --- README.MD | 4 ++-- requirements.txt | 7 +++---- src/bot/handlers/admins/router.py | 9 +++++++++ src/bot/handlers/misc.py | 7 +++++++ src/bot/handlers/users.py | 10 +++++++++- src/bot/utils/setup_bot.py | 4 ++++ src/bot/utils/setup_dispatcher.py | 7 +++++++ src/config/utils.py | 4 ++++ 8 files changed, 45 insertions(+), 7 deletions(-) diff --git a/README.MD b/README.MD index b41f35d..6be61a4 100644 --- a/README.MD +++ b/README.MD @@ -14,13 +14,13 @@ Use this bot for communicate with users in case you do not want to provide your ## Usage -Messages with an available [content type](./src/bot/handlers/users.py#L24) will be transfered to admin group or admin chat. +Messages with an **available content type** *(TEXT, ANIMATION, AUDIO, DOCUMENT, PHOTO, VIDEO, VOICE)* will be transferred to **admin group** or **admin chat**. *(See variable `chat_id` from [config.yaml](./deploy/example.config.yaml#L6))* If the transfer is successful, the requesting party will be notified. -Admin can answer to message by reply. The answer will be sent to the person who asked. +**Admin** can **answer** to message **by reply**. The answer will be sent to the person who asked. If the transfer is successful, the administrator will be notified. diff --git a/requirements.txt b/requirements.txt index 6e92fa8..c4aa642 100755 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,6 @@ -aiogram==3.1.0 -sulguk==0.5.0 +aiogram==3.1.1 +sulguk==0.6.0 pydantic-settings==2.0.3 -pyaml==23.9.6 +pyaml==23.9.7 structlog~=23.1.0 -# asyncio speedup uvloop==0.17.0; sys_platform == 'linux' diff --git a/src/bot/handlers/admins/router.py b/src/bot/handlers/admins/router.py index e9512cb..3260cfd 100644 --- a/src/bot/handlers/admins/router.py +++ b/src/bot/handlers/admins/router.py @@ -16,6 +16,15 @@ async def reply_to_user( message: Message, bot: Bot, messages: Messages, errors: Errors, **kwargs ): + """ + Answer to user by reply from admin chat or group + :param message: + :param bot: + :param messages: + :param errors: + :param kwargs: + :return: + """ try: user_id = extract_id(message.reply_to_message) except ValueError as ex: diff --git a/src/bot/handlers/misc.py b/src/bot/handlers/misc.py index 2946bd1..bc36b41 100644 --- a/src/bot/handlers/misc.py +++ b/src/bot/handlers/misc.py @@ -14,6 +14,13 @@ Command("start", "help"), ) # type: ignore async def start_help_handler(message: Message, messages: Messages, **kwargs) -> None: + """ + Handle /start or /help message + :param message: + :param messages: + :param kwargs: + :return: + """ await message.answer( messages.help_message, disable_web_page_preview=True, diff --git a/src/bot/handlers/users.py b/src/bot/handlers/users.py index b19f6d7..4e56fc0 100644 --- a/src/bot/handlers/users.py +++ b/src/bot/handlers/users.py @@ -11,7 +11,6 @@ router = Router(name="users") -# process messages only from PM @router.message(F.chat.id == F.from_user.id) # type: ignore async def handle_user_message( message: Message, @@ -21,6 +20,15 @@ async def handle_user_message( errors: Errors, **kwargs, ): + """Handle user message and send it to admin chat (group) + :param message: + :param bot: + :param chat_id: + :param messages: + :param errors: + :param kwargs: + :return: + """ if message.content_type not in ( ContentType.TEXT, ContentType.ANIMATION, diff --git a/src/bot/utils/setup_bot.py b/src/bot/utils/setup_bot.py index 36ca7d7..402205f 100644 --- a/src/bot/utils/setup_bot.py +++ b/src/bot/utils/setup_bot.py @@ -7,6 +7,10 @@ async def setup_bot(config: BotConfig) -> Bot: + """ + :param config: + :return: + """ bot: Bot = Bot( token=config.token.get_secret_value(), ) diff --git a/src/bot/utils/setup_dispatcher.py b/src/bot/utils/setup_dispatcher.py index 68b44b5..f82e134 100644 --- a/src/bot/utils/setup_dispatcher.py +++ b/src/bot/utils/setup_dispatcher.py @@ -12,6 +12,13 @@ def setup_dispatcher( logger: BoundLogger, chat_id: int, messages: Messages, errors: Errors ) -> Dispatcher: + """ + :param logger: + :param chat_id: + :param messages: + :param errors: + :return: + """ dp: Dispatcher = Dispatcher( storage=MemoryStorage(), logger=logger, diff --git a/src/config/utils.py b/src/config/utils.py index 001dc55..7243251 100644 --- a/src/config/utils.py +++ b/src/config/utils.py @@ -4,6 +4,10 @@ def load_config(config_path: str) -> Config: + """ + :param config_path: + :return: + """ with open(file=config_path, mode="rb") as fh: raw_data: dict = yaml.load(stream=fh, Loader=yaml.FullLoader) config: Config = Config.model_validate(raw_data)