From bb23c0aef62ef54205b776fef2fe4e90b71322e4 Mon Sep 17 00:00:00 2001 From: Taras Terletskyi <888784+tropicoo@users.noreply.github.com> Date: Tue, 28 Mar 2023 01:19:16 +0300 Subject: [PATCH] Version 1.3 --- README.md | 2 +- RELEASES.md | 18 ++++++++++++++++++ app_bot/bot/core/bot/launcher.py | 10 +++++++--- app_bot/bot/core/callbacks.py | 17 +++++++++++++++-- app_bot/bot/version.py | 2 +- 5 files changed, 42 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 5656e08..fe87bc3 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Simple and reliable YouTube Download Telegram Bot. -Version: 1.2.1. [Release details](RELEASES.md). +Version: 1.3. [Release details](RELEASES.md). ![frames](.assets/download_success.png) diff --git a/RELEASES.md b/RELEASES.md index 850ee80..42b6d1c 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,3 +1,21 @@ +## Release 1.3 + +Release date: March 28, 2023 + +## New Features + +- Now any user which is in the configured group with the bot can send the link + +## Important + +N/A + +## Misc + +N/A + +--- + ## Release 1.2.1 Release date: March 22, 2023 diff --git a/app_bot/bot/core/bot/launcher.py b/app_bot/bot/core/bot/launcher.py index 93ff8ee..e356ba3 100644 --- a/app_bot/bot/core/bot/launcher.py +++ b/app_bot/bot/core/bot/launcher.py @@ -43,9 +43,13 @@ class BotLauncher: self._bot.add_handler( MessageHandler( cb.on_message, - filters=filters.user(list(self._bot.allowed_users.keys())) - & filters.chat(list(self._bot.allowed_users.keys())) - & filters.regex(self.REGEX_NOT_START_WITH_SLASH), + filters=( + filters.regex(self.REGEX_NOT_START_WITH_SLASH) + & ( + filters.user(list(self._bot.allowed_users.keys())) + | filters.chat(list(self._bot.allowed_users.keys())) + ) + ), ), ) diff --git a/app_bot/bot/core/callbacks.py b/app_bot/bot/core/callbacks.py index 002752b..389a871 100644 --- a/app_bot/bot/core/callbacks.py +++ b/app_bot/bot/core/callbacks.py @@ -1,6 +1,6 @@ import logging -from pyrogram.enums import ParseMode +from pyrogram.enums import ChatType, ParseMode from pyrogram.types import Message from yt_shared.emoji import SUCCESS_EMOJI from yt_shared.enums import TelegramChatType @@ -48,9 +48,22 @@ class TelegramCallback: reply_to_message_id=message.id, ) + @staticmethod + def _get_user_id(message: Message) -> int: + """Make explicit selection to not forget how this works since we just can return + `message.chat.id` for all cases. + """ + match message.chat.type: + case ChatType.PRIVATE: + return message.from_user.id + case ChatType.GROUP: + return message.chat.id + case _: + return message.chat.id + def _parse_urls(self, message: Message) -> list[URL]: bot: VideoBot = message._client # noqa - user = bot.allowed_users[message.from_user.id] + user = bot.allowed_users[self._get_user_id(message)] return [ URL( url=url, diff --git a/app_bot/bot/version.py b/app_bot/bot/version.py index 3f262a6..6f4fa58 100644 --- a/app_bot/bot/version.py +++ b/app_bot/bot/version.py @@ -1 +1 @@ -__version__ = '1.2.1' +__version__ = '1.3'