From adf6791107fde8364b29164a1d7f110bbcaebf9b Mon Sep 17 00:00:00 2001 From: Shrimadhav U K Date: Mon, 1 Nov 2021 15:32:09 +0530 Subject: [PATCH 01/19] update Python --- Procfile | 2 +- app.json | 8 +++----- runtime.txt | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Procfile b/Procfile index 8574398..8153596 100644 --- a/Procfile +++ b/Procfile @@ -1 +1 @@ -worker: python -m bot +worker: python -m bot \ No newline at end of file diff --git a/app.json b/app.json index 87ac777..3431f9e 100644 --- a/app.json +++ b/app.json @@ -29,11 +29,9 @@ "description": "Create a PyroGram User Session, using https://generatestringsession.spechide.repl.run/" } }, - "buildpacks": [ - { - "url": "heroku/python" - } - ], + "buildpacks": [{ + "url": "heroku/python" + }], "formation": { "worker": { "quantity": 1, diff --git a/runtime.txt b/runtime.txt index 1124509..88f4ef2 100644 --- a/runtime.txt +++ b/runtime.txt @@ -1 +1 @@ -python-3.8.5 \ No newline at end of file +python-3.9.5 \ No newline at end of file From 35eeae5b53fb2203ba097d5f59d94cdbeab106fa Mon Sep 17 00:00:00 2001 From: Shrimadhav U K Date: Mon, 1 Nov 2021 15:32:34 +0530 Subject: [PATCH 02/19] fix heroku stack --- app.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app.json b/app.json index 3431f9e..a4b7092 100644 --- a/app.json +++ b/app.json @@ -37,5 +37,6 @@ "quantity": 1, "size": "free" } - } + }, + "stack": "heroku-20" } \ No newline at end of file From c9d6663f3c0a7ff2d64af173786d633771f2af8f Mon Sep 17 00:00:00 2001 From: Shrimadhav U K Date: Mon, 1 Nov 2021 15:33:13 +0530 Subject: [PATCH 03/19] this closes #1 --- bot/__init__.py | 6 +++++- bot/plugins/del_all.py | 10 +++++++--- bot/plugins/del_selective.py | 13 +++++++++---- requirements.txt | 4 ++-- sample_config.env | 2 ++ 5 files changed, 25 insertions(+), 10 deletions(-) diff --git a/bot/__init__.py b/bot/__init__.py index 1c60fe6..66f7e1b 100644 --- a/bot/__init__.py +++ b/bot/__init__.py @@ -50,6 +50,9 @@ TG_MIN_SEL_MESG = int(get_config("TG_MIN_SEL_MESG", 0)) # a dictionary to store the currently running processes AKTIFPERINTAH = {} +# should the user / bot leave the chat after finishing tasks +SHTL_USR_HCAT_QO = bool(get_config("SHTL_USR_HCAT_QO", False)) +SHTL_BOT_HCAT_QO = bool(get_config("SHTL_BOT_HCAT_QO", False)) logging.basicConfig( @@ -77,7 +80,8 @@ def LOGGER(name: str) -> logging.Logger: GIT_REPO_LINK = "https://github.com/SpEcHiDe/DeleteMessagesRoBot" """ strings to be used in the bot """ START_MESSAGE = get_config("START_MESSAGE", ( - "I'm a bot that can delete all your channel or supergroup messages. " + "I'm a bot that can delete all " + "your channel or supergroup messages. " "\n\n" f"To use me: read 👉 {REQD_PERMISSIONS} 👈" "\n\n" diff --git a/bot/plugins/del_all.py b/bot/plugins/del_all.py index 1381cb8..b78a4b3 100644 --- a/bot/plugins/del_all.py +++ b/bot/plugins/del_all.py @@ -22,7 +22,9 @@ from bot import ( BEGINNING_DEL_ALL_MESSAGE, DEL_ALL_COMMAND, - IN_CORRECT_PERMISSIONS_MESSAGE + IN_CORRECT_PERMISSIONS_MESSAGE, + SHTL_BOT_HCAT_QO, + SHTL_USR_HCAT_QO ) from bot.bot import Bot from bot.helpers.custom_filter import allowed_chat_filter @@ -68,5 +70,7 @@ async def del_all_command_fn(client: Bot, message: Message): ) # leave the chat, after task is done - await client.USER.leave_chat(message.chat.id) - await client.leave_chat(message.chat.id) + if SHTL_USR_HCAT_QO: + await client.USER.leave_chat(message.chat.id) + if SHTL_BOT_HCAT_QO: + await client.leave_chat(message.chat.id) diff --git a/bot/plugins/del_selective.py b/bot/plugins/del_selective.py index 51621a9..9a0f5ac 100644 --- a/bot/plugins/del_selective.py +++ b/bot/plugins/del_selective.py @@ -27,6 +27,8 @@ IN_CORRECT_PERMISSIONS_MESSAGE, NOT_USED_DEL_FROM_DEL_TO_MESSAGE, SEL_DEL_COMMAND, + SHTL_BOT_HCAT_QO, + SHTL_USR_HCAT_QO, TL_FILE_TYPES ) from bot.bot import Bot @@ -91,7 +93,8 @@ async def del_selective_command_fn(client: Bot, message: Message): DEL_TO_COMMAND ) except AttributeError: - max_message_id = status_message.message_id if status_message else message.message_id + max_message_id = status_message.message_id if \ + status_message else message.message_id await get_messages( client.USER, @@ -105,7 +108,7 @@ async def del_selective_command_fn(client: Bot, message: Message): if status_message: await status_message.delete() await message.delete() - except: + except: # noqa: E722 pass try: @@ -114,5 +117,7 @@ async def del_selective_command_fn(client: Bot, message: Message): pass # leave the chat, after task is done - await client.USER.leave_chat(message.chat.id) - await client.leave_chat(message.chat.id) + if SHTL_USR_HCAT_QO: + await client.USER.leave_chat(message.chat.id) + if SHTL_BOT_HCAT_QO: + await client.leave_chat(message.chat.id) diff --git a/requirements.txt b/requirements.txt index 2d50347..4946d20 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -Pyrogram==1.0.7 -TgCrypto==1.2.1 +Pyrogram==1.2.9 +TgCrypto==1.2.2 python-dotenv>=0.10 diff --git a/sample_config.env b/sample_config.env index 5b4d5e7..7818316 100644 --- a/sample_config.env +++ b/sample_config.env @@ -25,6 +25,8 @@ # LOG_FILE_ZZGEVC= # TG_MAX_SEL_MESG= # TG_MIN_SEL_MESG= +# SHTL_USR_HCAT_QO= +# SHTL_BOT_HCAT_QO # ----------- CUSTOM STRINGS ----------- # From 866cb17685e48c779da637b8f1d938d605a44dbd Mon Sep 17 00:00:00 2001 From: Shrimadhav U K Date: Mon, 1 Nov 2021 15:38:54 +0530 Subject: [PATCH 04/19] this fixes #4 --- bot/__init__.py | 3 +++ bot/bot.py | 6 ++++-- bot/helpers/make_user_join_chat.py | 4 +++- bot/user.py | 4 +++- sample_config.env | 3 ++- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/bot/__init__.py b/bot/__init__.py index 66f7e1b..d1221b9 100644 --- a/bot/__init__.py +++ b/bot/__init__.py @@ -43,6 +43,9 @@ # given the amount of sql data accesses, # and the way python asynchronous calls work. TG_BOT_WORKERS = int(get_config("TG_BOT_WORKERS", "4")) +# add an auto sleep time, +# in the Pyrogram Client +TG_SLEEP_THRESHOLD = int(get_config("TG_SLEEP_THRESHOLD", 10)) # path to store LOG files LOG_FILE_ZZGEVC = get_config("LOG_FILE_ZZGEVC", "MessageDeletErBot.log") # number of messages that can be deleted in One Request, in Telegram diff --git a/bot/bot.py b/bot/bot.py index fbaae1c..ddf1ae1 100644 --- a/bot/bot.py +++ b/bot/bot.py @@ -26,7 +26,8 @@ LOGGER, TG_BOT_SESSION, TG_BOT_TOKEN, - TG_BOT_WORKERS + TG_BOT_WORKERS, + TG_SLEEP_THRESHOLD ) from .user import User @@ -45,7 +46,8 @@ def __init__(self): "root": "bot/plugins" }, workers=TG_BOT_WORKERS, - bot_token=TG_BOT_TOKEN + bot_token=TG_BOT_TOKEN, + sleep_threshold=TG_SLEEP_THRESHOLD ) self.LOGGER = LOGGER diff --git a/bot/helpers/make_user_join_chat.py b/bot/helpers/make_user_join_chat.py index add6cc9..dad4638 100644 --- a/bot/helpers/make_user_join_chat.py +++ b/bot/helpers/make_user_join_chat.py @@ -42,6 +42,7 @@ async def make_chat_user_join( if not _existing_permissions.can_delete_messages: await message.chat.promote_member( user_id, + can_manage_chat=False, can_change_info=False, can_post_messages=False, can_edit_messages=False, @@ -49,6 +50,7 @@ async def make_chat_user_join( can_restrict_members=False, can_invite_users=False, can_pin_messages=False, - can_promote_members=False + can_promote_members=False, + can_manage_voice_chats=False ) return True, None diff --git a/bot/user.py b/bot/user.py index 30b269c..2ee0f2e 100644 --- a/bot/user.py +++ b/bot/user.py @@ -25,6 +25,7 @@ APP_ID, LOGGER, TG_BOT_WORKERS, + TG_SLEEP_THRESHOLD, TG_USER_SESSION ) @@ -37,7 +38,8 @@ def __init__(self): TG_USER_SESSION, api_hash=API_HASH, api_id=APP_ID, - workers=TG_BOT_WORKERS + workers=TG_BOT_WORKERS, + sleep_threshold=TG_SLEEP_THRESHOLD ) self.LOGGER = LOGGER diff --git a/sample_config.env b/sample_config.env index 7818316..3b85163 100644 --- a/sample_config.env +++ b/sample_config.env @@ -22,11 +22,12 @@ # TG_BOT_SESSION= # TG_BOT_WORKERS= +# TG_SLEEP_THRESHOLD= # LOG_FILE_ZZGEVC= # TG_MAX_SEL_MESG= # TG_MIN_SEL_MESG= # SHTL_USR_HCAT_QO= -# SHTL_BOT_HCAT_QO +# SHTL_BOT_HCAT_QO= # ----------- CUSTOM STRINGS ----------- # From 5db9c173591e10b5a507e4296a77d9d41f8d19d1 Mon Sep 17 00:00:00 2001 From: Shrimadhav U K Date: Wed, 1 Dec 2021 08:40:09 +0530 Subject: [PATCH 05/19] =?UTF-8?q?temp.=20limitations=20till=20@Pyrogram=20?= =?UTF-8?q?update=20=F0=9F=A4=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bot/helpers/make_user_join_chat.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bot/helpers/make_user_join_chat.py b/bot/helpers/make_user_join_chat.py index dad4638..89473df 100644 --- a/bot/helpers/make_user_join_chat.py +++ b/bot/helpers/make_user_join_chat.py @@ -30,8 +30,9 @@ async def make_chat_user_join( message: Message ): chat_invite_link = await message.chat.export_invite_link() + izciul = chat_invite_link.replace("/+", "/joinchat/") try: - await client.join_chat(chat_invite_link) + await client.join_chat(izciul) except UserAlreadyParticipant: pass except (InviteHashExpired, InviteHashInvalid) as e: From ed40ef4a0df5a16b36cb1496dd2eb9046c7b2094 Mon Sep 17 00:00:00 2001 From: Shrimadhav U K Date: Sun, 16 Jan 2022 14:12:47 +0530 Subject: [PATCH 06/19] update Pyrogram --- requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 4946d20..be7c3ed 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -Pyrogram==1.2.9 -TgCrypto==1.2.2 +Pyrogram==1.3.5 +TgCrypto==1.2.3 python-dotenv>=0.10 From 00d968b83188cd5d1c39cfb9bd956f0d3f30c84f Mon Sep 17 00:00:00 2001 From: Shrimadhav U K Date: Sat, 29 Jan 2022 23:29:53 +0530 Subject: [PATCH 07/19] (really) Update Pyrogram, and Remove Last TWO commits --- bot/helpers/make_user_join_chat.py | 3 +-- requirements.txt | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/bot/helpers/make_user_join_chat.py b/bot/helpers/make_user_join_chat.py index 89473df..dad4638 100644 --- a/bot/helpers/make_user_join_chat.py +++ b/bot/helpers/make_user_join_chat.py @@ -30,9 +30,8 @@ async def make_chat_user_join( message: Message ): chat_invite_link = await message.chat.export_invite_link() - izciul = chat_invite_link.replace("/+", "/joinchat/") try: - await client.join_chat(izciul) + await client.join_chat(chat_invite_link) except UserAlreadyParticipant: pass except (InviteHashExpired, InviteHashInvalid) as e: diff --git a/requirements.txt b/requirements.txt index be7c3ed..e385da4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -Pyrogram==1.3.5 +Pyrogram==1.3.6 TgCrypto==1.2.3 python-dotenv>=0.10 From 921d04662b1ec835b0b25c1bf77813f7fd0e23ee Mon Sep 17 00:00:00 2001 From: Shrimadhav U K Date: Sat, 29 Jan 2022 23:49:51 +0530 Subject: [PATCH 08/19] convenient method to get chat id and message id from message link --- bot/helpers/delall_bot_links.py | 34 +++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 bot/helpers/delall_bot_links.py diff --git a/bot/helpers/delall_bot_links.py b/bot/helpers/delall_bot_links.py new file mode 100644 index 0000000..2d13cb0 --- /dev/null +++ b/bot/helpers/delall_bot_links.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# (c) Shrimadhav U K +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. + +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +from typing import Tuple, Union + + +def extract_c_m_ids(message_link: str) -> Tuple[Union[str, int], int]: + p_m_link = message_link.split("/") + chat_id, message_id = None, None + if len(p_m_link) == 6: + # private link + if p_m_link[3] == "c": + # the Telegram private link + chat_id, message_id = int("-100" + p_m_link[4]), int(p_m_link[5]) + elif p_m_link[3] == "DMCATelegramBot": + # bleck magick + chat_id, message_id = int(p_m_link[4]), int(p_m_link[5]) + elif len(p_m_link) == 5: + # public link + chat_id, message_id = str("@" + p_m_link[3]), int(p_m_link[4]) + return chat_id, message_id From 52fc9024782e8b486f80e5f4190a95ff60adf681 Mon Sep 17 00:00:00 2001 From: Shrimadhav U K Date: Sat, 29 Jan 2022 23:50:34 +0530 Subject: [PATCH 09/19] get a machine readable format, from the human readable message of 454000 --- bot/helpers/gulmnek.py | 48 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 bot/helpers/gulmnek.py diff --git a/bot/helpers/gulmnek.py b/bot/helpers/gulmnek.py new file mode 100644 index 0000000..d357595 --- /dev/null +++ b/bot/helpers/gulmnek.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# (c) Shrimadhav U K +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. + +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +from pyrogram.types import Message +from .delall_bot_links import extract_c_m_ids + + +def knemblook( + message: Message +): + _store_r = {} + entities = ( + message.entities or + message.caption_entities or + [] + ) + text = ( + message.text or + message.caption or + "" + ) + if message and text and len(entities) > 0: + for one_entity in entities: + if one_entity.type == "url": + _url = text[ + one_entity.offset:one_entity.offset + one_entity.length + ] + elif one_entity.type == "text_link": + _url = one_entity.url + if _url: + chat_id, message_id = extract_c_m_ids(_url) + if chat_id not in _store_r: + _store_r[chat_id] = [] + _store_r[chat_id].append(message_id) + return _store_r From b9040a2297ea7867e781a7c93bd700c0c6d2d683 Mon Sep 17 00:00:00 2001 From: Shrimadhav U K Date: Tue, 8 Feb 2022 19:53:22 +0530 Subject: [PATCH 10/19] add helper method to check permissions --- bot/helpers/help_for_14121.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 bot/helpers/help_for_14121.py diff --git a/bot/helpers/help_for_14121.py b/bot/helpers/help_for_14121.py new file mode 100644 index 0000000..8a0aa9c --- /dev/null +++ b/bot/helpers/help_for_14121.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# (c) Shrimadhav U K +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. + +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +from pyrogram.errors import ( + UserNotParticipant +) +from bot.bot import Bot + + +async def check_perm(client: Bot, chat_id: int, user_id: int) -> bool: + try: + _a_ = await client.get_chat_member( + chat_id, + user_id + ) + except UserNotParticipant: + return False + else: + if _a_.can_delete_messages: + return True + else: + return False From 282328e899750e09d428b202eacefd41209bbb9b Mon Sep 17 00:00:00 2001 From: Shrimadhav U K Date: Tue, 8 Feb 2022 19:59:53 +0530 Subject: [PATCH 11/19] add delete messages by forwarding messages from @DMCATelegram --- bot/__init__.py | 6 +++ bot/plugins/dmca_del.py | 99 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+) create mode 100644 bot/plugins/dmca_del.py diff --git a/bot/__init__.py b/bot/__init__.py index d1221b9..dea1d8c 100644 --- a/bot/__init__.py +++ b/bot/__init__.py @@ -114,6 +114,12 @@ def LOGGER(name: str) -> logging.Logger: f"before using /{SEL_DEL_COMMAND}" ) ) +THANK_YOU_MESSAGE = get_config( + "THANK_YOU_MESSAGE", ( + "Thank You for using me, " + f"Join {REQD_PERMISSIONS} to support this Telegram Bot" + ) +) TL_FILE_TYPES = ( "photo", "animation", diff --git a/bot/plugins/dmca_del.py b/bot/plugins/dmca_del.py new file mode 100644 index 0000000..d35c19e --- /dev/null +++ b/bot/plugins/dmca_del.py @@ -0,0 +1,99 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# (c) Shrimadhav U K +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. + +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +from pyrogram import filters +from pyrogram.types import Message +from pyrogram.errors import ( + ChatAdminRequired +) +from bot import ( + BEGINNING_DEL_ALL_MESSAGE, + THANK_YOU_MESSAGE, + IN_CORRECT_PERMISSIONS_MESSAGE, + SHTL_BOT_HCAT_QO, + SHTL_USR_HCAT_QO +) +from bot.bot import Bot +from bot.helpers.gulmnek import knemblook +from bot.helpers.delete_messages import mass_delete_messages +from bot.helpers.help_for_14121 import check_perm +from bot.helpers.make_user_join_chat import make_chat_user_join + + +@Bot.on_message( + filters.incoming & + filters.create( + lambda _, __, msg: ( + msg and + msg.chat and + msg.from_user and + # we don't want to deal with + # Telegram weirdness for now + msg.chat.type == "private" and + msg.forward_from and + msg.forward_from.id == 454000 + ), + "Incoming454000Messages" + ) +) +async def dmca_spec_del_nf(client: Bot, message: Message): + bot_id = await client.get_me() + status_message = await message.reply_text( + BEGINNING_DEL_ALL_MESSAGE, + quote=True + ) + all_id_stores_ = knemblook(message) + for chat_id in all_id_stores_: + # 1) check bot permissions in chat_id + aqo = check_perm(client, chat_id, message.from_user.id) + if not aqo: + continue + qbo = check_perm(client, chat_id, bot_id) + if not qbo: + await status_message.reply_text( + IN_CORRECT_PERMISSIONS_MESSAGE, + quote=True + ) + continue + heck_mesg = await client.get_messages( + chat_id, + all_id_stores_[chat_id][0], + replies=0 + ) + # 2) make user join chat + await make_chat_user_join( + client, + client.USER_ID, + heck_mesg + ) + + # 3) delete the list of messages + await mass_delete_messages( + client.USER, + chat_id, + all_id_stores_[chat_id] + ) + + # 4) leave chat + # leave the chat, after task is done + if SHTL_USR_HCAT_QO: + await client.USER.leave_chat(chat_id) + if SHTL_BOT_HCAT_QO: + await client.leave_chat(chat_id) + + await status_message.edit_text( + THANK_YOU_MESSAGE + ) From 531f2fd3f6d803985f6f4ec4ab291969dc63eb0f Mon Sep 17 00:00:00 2001 From: Shrimadhav U K Date: Tue, 8 Feb 2022 20:02:10 +0530 Subject: [PATCH 12/19] update --- bot/plugins/del_all.py | 10 +++++++++- bot/plugins/del_selective.py | 8 ++++++++ sample_config.env | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/bot/plugins/del_all.py b/bot/plugins/del_all.py index b78a4b3..2a9e2e9 100644 --- a/bot/plugins/del_all.py +++ b/bot/plugins/del_all.py @@ -24,7 +24,8 @@ DEL_ALL_COMMAND, IN_CORRECT_PERMISSIONS_MESSAGE, SHTL_BOT_HCAT_QO, - SHTL_USR_HCAT_QO + SHTL_USR_HCAT_QO, + THANK_YOU_MESSAGE ) from bot.bot import Bot from bot.helpers.custom_filter import allowed_chat_filter @@ -74,3 +75,10 @@ async def del_all_command_fn(client: Bot, message: Message): await client.USER.leave_chat(message.chat.id) if SHTL_BOT_HCAT_QO: await client.leave_chat(message.chat.id) + + # edit with channel message ads, + # after process is completed + if status_message: + await status_message.edit_text( + THANK_YOU_MESSAGE + ) diff --git a/bot/plugins/del_selective.py b/bot/plugins/del_selective.py index 9a0f5ac..e4d48dd 100644 --- a/bot/plugins/del_selective.py +++ b/bot/plugins/del_selective.py @@ -29,6 +29,7 @@ SEL_DEL_COMMAND, SHTL_BOT_HCAT_QO, SHTL_USR_HCAT_QO, + THANK_YOU_MESSAGE, TL_FILE_TYPES ) from bot.bot import Bot @@ -121,3 +122,10 @@ async def del_selective_command_fn(client: Bot, message: Message): await client.USER.leave_chat(message.chat.id) if SHTL_BOT_HCAT_QO: await client.leave_chat(message.chat.id) + + # edit with channel message ads, + # after process is completed + if status_message: + await status_message.edit_text( + THANK_YOU_MESSAGE + ) diff --git a/sample_config.env b/sample_config.env index 3b85163..5d655ac 100644 --- a/sample_config.env +++ b/sample_config.env @@ -36,6 +36,7 @@ # IN_CORRECT_PERMISSIONS_MESSAGE= # BEGINNING_SEL_DEL_MESSAGE= # NOT_USED_DEL_FROM_DEL_TO_MESSAGE= +# THANK_YOU_MESSAGE= # ----------- CUSTOM COMMANDS ----------- # From ba12d1a46331050a3fb4d020c6ec14c3bc60aabd Mon Sep 17 00:00:00 2001 From: Shrimadhav U K Date: Tue, 8 Feb 2022 20:03:05 +0530 Subject: [PATCH 13/19] update pyrogram --- app.json | 2 +- requirements.txt | 2 +- runtime.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app.json b/app.json index a4b7092..dec5335 100644 --- a/app.json +++ b/app.json @@ -26,7 +26,7 @@ "description": "Obtain a Telegram bot token by contacting @BotFather" }, "TG_USER_SESSION": { - "description": "Create a PyroGram User Session, using https://generatestringsession.spechide.repl.run/" + "description": "Create a PyroGram User Session, using https://t.me/useTGxBot" } }, "buildpacks": [{ diff --git a/requirements.txt b/requirements.txt index e385da4..c9fb02b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -Pyrogram==1.3.6 +Pyrogram==1.4.1 TgCrypto==1.2.3 python-dotenv>=0.10 diff --git a/runtime.txt b/runtime.txt index 88f4ef2..d667043 100644 --- a/runtime.txt +++ b/runtime.txt @@ -1 +1 @@ -python-3.9.5 \ No newline at end of file +python-3.9.7 \ No newline at end of file From d542def6f13a230bb160654474fe98385c176920 Mon Sep 17 00:00:00 2001 From: Shrimadhav U K Date: Tue, 8 Feb 2022 20:03:46 +0530 Subject: [PATCH 14/19] fixes --- bot/helpers/help_for_14121.py | 2 +- bot/plugins/dmca_del.py | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/bot/helpers/help_for_14121.py b/bot/helpers/help_for_14121.py index 8a0aa9c..e99affb 100644 --- a/bot/helpers/help_for_14121.py +++ b/bot/helpers/help_for_14121.py @@ -32,4 +32,4 @@ async def check_perm(client: Bot, chat_id: int, user_id: int) -> bool: if _a_.can_delete_messages: return True else: - return False + return False diff --git a/bot/plugins/dmca_del.py b/bot/plugins/dmca_del.py index d35c19e..ad0e0fa 100644 --- a/bot/plugins/dmca_del.py +++ b/bot/plugins/dmca_del.py @@ -16,9 +16,6 @@ from pyrogram import filters from pyrogram.types import Message -from pyrogram.errors import ( - ChatAdminRequired -) from bot import ( BEGINNING_DEL_ALL_MESSAGE, THANK_YOU_MESSAGE, From 2d6be638eee2cbbc527715eab7f66ef5265df52f Mon Sep 17 00:00:00 2001 From: Shrimadhav U K Date: Fri, 15 Apr 2022 08:57:00 +0530 Subject: [PATCH 15/19] update pyrogram dependancy --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index c9fb02b..91cbfb2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -Pyrogram==1.4.1 +Pyrogram==1.4.15 TgCrypto==1.2.3 python-dotenv>=0.10 From 35b1f80cc3bb816fa306e3e8685b9152cd5455ce Mon Sep 17 00:00:00 2001 From: Shrimadhav U K Date: Fri, 15 Apr 2022 08:57:52 +0530 Subject: [PATCH 16/19] for issue #15 --- bot/helpers/make_user_join_chat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot/helpers/make_user_join_chat.py b/bot/helpers/make_user_join_chat.py index dad4638..633c5d9 100644 --- a/bot/helpers/make_user_join_chat.py +++ b/bot/helpers/make_user_join_chat.py @@ -38,7 +38,7 @@ async def make_chat_user_join( return False, str(e) _existing_permissions = await message.chat.get_member(user_id) if _existing_permissions.status == "creator": - return True, None + return True, 140 if not _existing_permissions.can_delete_messages: await message.chat.promote_member( user_id, From 8f8803e266e0d63ef9f3edf9e0d7508328161349 Mon Sep 17 00:00:00 2001 From: Shrimadhav U K Date: Fri, 15 Apr 2022 08:59:14 +0530 Subject: [PATCH 17/19] no need to iter_messages to delete with updated @Telegram --- bot/plugins/del_all.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/bot/plugins/del_all.py b/bot/plugins/del_all.py index 2a9e2e9..b41313e 100644 --- a/bot/plugins/del_all.py +++ b/bot/plugins/del_all.py @@ -62,6 +62,26 @@ async def del_all_command_fn(client: Bot, message: Message): await message.delete() return + if ( + # don't know a better way :\ + str(message.chat.id).startswith("-100") and + # only creator of group can do this + s__ and + nop == 140 + ): + await client.USER.send( + DeleteHistory( + for_everyone=True, + channel=( + await client.USER.resolve_peer( + message.chat.id + ) + ), + max_id=0 + ) + ) + return + await get_messages( client.USER, message.chat.id, From a4e55b8628d81b4f67abca5f78fd141d107c2aeb Mon Sep 17 00:00:00 2001 From: Shrimadhav U K Date: Sat, 6 Aug 2022 16:11:38 +0530 Subject: [PATCH 18/19] update pyrogram --- bot/bot.py | 21 ++++++++++++++------ bot/helpers/custom_filter.py | 3 ++- bot/helpers/get_messages.py | 8 ++++---- bot/helpers/gulmnek.py | 6 ++++-- bot/helpers/make_user_join_chat.py | 6 ++++-- bot/plugins/del_all.py | 31 +++++++++++++++--------------- bot/plugins/del_from.py | 2 +- bot/plugins/del_selective.py | 5 +++-- bot/plugins/del_to.py | 2 +- bot/user.py | 15 +++++++++------ requirements.txt | 2 +- 11 files changed, 60 insertions(+), 41 deletions(-) diff --git a/bot/bot.py b/bot/bot.py index ddf1ae1..36f2442 100644 --- a/bot/bot.py +++ b/bot/bot.py @@ -20,6 +20,7 @@ Client, __version__ ) +from pyrogram.enums import ParseMode from . import ( API_HASH, APP_ID, @@ -34,33 +35,41 @@ class Bot(Client): """ modded client for MessageDeletERoBot """ + BOT_ID: int = None USER: User = None USER_ID: int = None def __init__(self): super().__init__( - TG_BOT_SESSION, + name=TG_BOT_SESSION, api_hash=API_HASH, api_id=APP_ID, plugins={ - "root": "bot/plugins" + "root": "bot.plugins", + "exclude": [ + "oatc" + ] }, workers=TG_BOT_WORKERS, bot_token=TG_BOT_TOKEN, - sleep_threshold=TG_SLEEP_THRESHOLD + sleep_threshold=TG_SLEEP_THRESHOLD, + parse_mode=ParseMode.HTML ) self.LOGGER = LOGGER async def start(self): await super().start() - usr_bot_me = await self.get_me() - self.set_parse_mode("html") + usr_bot_me = self.me + self.BOT_ID = usr_bot_me.id self.LOGGER(__name__).info( f"@{usr_bot_me.username} based on Pyrogram v{__version__} " ) self.USER, self.USER_ID = await User().start() # hack to get the entities in-memory - await self.USER.send_message(usr_bot_me.username, "this is a hack") + await self.USER.send_message( + usr_bot_me.username, + "join https://t.me/SpEcHlDe/857" + ) async def stop(self, *args): await super().stop() diff --git a/bot/helpers/custom_filter.py b/bot/helpers/custom_filter.py index e78d077..6965523 100644 --- a/bot/helpers/custom_filter.py +++ b/bot/helpers/custom_filter.py @@ -15,11 +15,12 @@ # along with this program. If not, see . from pyrogram import filters +from pyrogram.enums import ChatType from pyrogram.types import Message async def allowed_chat_filter_fn(_, __, m: Message): - return bool(m.chat and m.chat.type in {"channel", "supergroup"}) + return bool(m.chat and m.chat.type in [ChatType.CHANNEL, ChatType.SUPERGROUP]) allowed_chat_filter = filters.create(allowed_chat_filter_fn) diff --git a/bot/helpers/get_messages.py b/bot/helpers/get_messages.py index bc6aea2..e28663e 100644 --- a/bot/helpers/get_messages.py +++ b/bot/helpers/get_messages.py @@ -36,16 +36,16 @@ async def get_messages( limit=None ): if ( - min_message_id <= msg.message_id and - max_message_id >= msg.message_id + min_message_id <= msg.id and + max_message_id >= msg.id ): if len(filter_type_s) > 0: for filter_type in filter_type_s: obj = getattr(msg, filter_type) if obj: - messages_to_delete.append(msg.message_id) + messages_to_delete.append(msg.id) else: - messages_to_delete.append(msg.message_id) + messages_to_delete.append(msg.id) # append to the list, based on the condition if len(messages_to_delete) > TG_MAX_SEL_MESG: await mass_delete_messages( diff --git a/bot/helpers/gulmnek.py b/bot/helpers/gulmnek.py index d357595..655a7c4 100644 --- a/bot/helpers/gulmnek.py +++ b/bot/helpers/gulmnek.py @@ -15,6 +15,7 @@ # along with this program. If not, see . from pyrogram.types import Message +from pyrogram.enums import MessageEntityType from .delall_bot_links import extract_c_m_ids @@ -34,11 +35,12 @@ def knemblook( ) if message and text and len(entities) > 0: for one_entity in entities: - if one_entity.type == "url": + _url = None + if one_entity.type == MessageEntityType.URL: _url = text[ one_entity.offset:one_entity.offset + one_entity.length ] - elif one_entity.type == "text_link": + elif one_entity.type == MessageEntityType.TEXT_LINK: _url = one_entity.url if _url: chat_id, message_id = extract_c_m_ids(_url) diff --git a/bot/helpers/make_user_join_chat.py b/bot/helpers/make_user_join_chat.py index 633c5d9..093a36d 100644 --- a/bot/helpers/make_user_join_chat.py +++ b/bot/helpers/make_user_join_chat.py @@ -14,12 +14,13 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . - +from asyncio import sleep from pyrogram.errors import ( InviteHashExpired, InviteHashInvalid, UserAlreadyParticipant ) +from pyrogram.enums import ChatMemberStatus from pyrogram.types import Message from bot.bot import Bot @@ -36,8 +37,9 @@ async def make_chat_user_join( pass except (InviteHashExpired, InviteHashInvalid) as e: return False, str(e) + await sleep(7) _existing_permissions = await message.chat.get_member(user_id) - if _existing_permissions.status == "creator": + if _existing_permissions.status == ChatMemberStatus.OWNER: return True, 140 if not _existing_permissions.can_delete_messages: await message.chat.promote_member( diff --git a/bot/plugins/del_all.py b/bot/plugins/del_all.py index b41313e..59ff878 100644 --- a/bot/plugins/del_all.py +++ b/bot/plugins/del_all.py @@ -15,10 +15,11 @@ # along with this program. If not, see . from pyrogram import filters -from pyrogram.types import Message from pyrogram.errors import ( ChatAdminRequired ) +from pyrogram.raw.functions.channels import DeleteHistory +from pyrogram.types import Message from bot import ( BEGINNING_DEL_ALL_MESSAGE, DEL_ALL_COMMAND, @@ -80,21 +81,21 @@ async def del_all_command_fn(client: Bot, message: Message): max_id=0 ) ) - return - - await get_messages( - client.USER, - message.chat.id, - 0, - status_message.message_id if status_message else message.message_id, - [] - ) - # leave the chat, after task is done - if SHTL_USR_HCAT_QO: - await client.USER.leave_chat(message.chat.id) - if SHTL_BOT_HCAT_QO: - await client.leave_chat(message.chat.id) + else: + await get_messages( + client.USER, + message.chat.id, + 0, + status_message.id if status_message else message.id, + [] + ) + + # leave the chat, after task is done + if SHTL_USR_HCAT_QO: + await client.USER.leave_chat(message.chat.id) + if SHTL_BOT_HCAT_QO: + await client.leave_chat(message.chat.id) # edit with channel message ads, # after process is completed diff --git a/bot/plugins/del_from.py b/bot/plugins/del_from.py index aafbe3d..454acf4 100644 --- a/bot/plugins/del_from.py +++ b/bot/plugins/del_from.py @@ -45,7 +45,7 @@ async def del_from_command_fn(client: Bot, message: Message): message.chat.id ][ DEL_FROM_COMMAND - ] = message.reply_to_message.message_id + ] = message.reply_to_message.id if status_message: await status_message.edit_text( "saved starting message_id. " diff --git a/bot/plugins/del_selective.py b/bot/plugins/del_selective.py index e4d48dd..5c3b95c 100644 --- a/bot/plugins/del_selective.py +++ b/bot/plugins/del_selective.py @@ -94,8 +94,8 @@ async def del_selective_command_fn(client: Bot, message: Message): DEL_TO_COMMAND ) except AttributeError: - max_message_id = status_message.message_id if \ - status_message else message.message_id + max_message_id = status_message.id if \ + status_message else message.id await get_messages( client.USER, @@ -108,6 +108,7 @@ async def del_selective_command_fn(client: Bot, message: Message): try: if status_message: await status_message.delete() + status_message = None await message.delete() except: # noqa: E722 pass diff --git a/bot/plugins/del_to.py b/bot/plugins/del_to.py index c449288..61e27b9 100644 --- a/bot/plugins/del_to.py +++ b/bot/plugins/del_to.py @@ -45,7 +45,7 @@ async def del_to_command_fn(client: Bot, message: Message): message.chat.id ][ DEL_TO_COMMAND - ] = message.reply_to_message.message_id + ] = message.reply_to_message.id if status_message: await status_message.edit_text( "saved ending message_id. " diff --git a/bot/user.py b/bot/user.py index 2ee0f2e..79d1624 100644 --- a/bot/user.py +++ b/bot/user.py @@ -20,6 +20,7 @@ Client, __version__ ) +from pyrogram.enums import ParseMode from . import ( API_HASH, APP_ID, @@ -35,23 +36,25 @@ class User(Client): def __init__(self): super().__init__( - TG_USER_SESSION, + name="DeleteUser", + in_memory=True, + session_string=TG_USER_SESSION, api_hash=API_HASH, api_id=APP_ID, workers=TG_BOT_WORKERS, - sleep_threshold=TG_SLEEP_THRESHOLD + sleep_threshold=TG_SLEEP_THRESHOLD, + parse_mode=ParseMode.HTML ) self.LOGGER = LOGGER async def start(self): await super().start() - usr_bot_me = await self.get_me() - self.set_parse_mode("html") + usr_bot_me = self.me self.LOGGER(__name__).info( - f"@{usr_bot_me.username} based on Pyrogram v{__version__} " + f"{usr_bot_me} based on Pyrogram v{__version__} " ) return (self, usr_bot_me.id) async def stop(self, *args): await super().stop() - self.LOGGER(__name__).info("Bot stopped. Bye.") + self.LOGGER(__name__).info("User stopped. Bye.") diff --git a/requirements.txt b/requirements.txt index 91cbfb2..8a98c3e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -Pyrogram==1.4.15 +Pyrogram==2.0.35 TgCrypto==1.2.3 python-dotenv>=0.10 From 7b07fc9828e00c11d9c1054792aa36578a271e00 Mon Sep 17 00:00:00 2001 From: Shrimadhav U K Date: Thu, 11 Apr 2024 20:28:26 +0530 Subject: [PATCH 19/19] Update Pyrogram version --- app.json | 6 ------ bot/helpers/make_user_join_chat.py | 18 +++++++----------- bot/plugins/del_all.py | 15 ++++++++++----- bot/plugins/del_from.py | 8 +++++--- bot/plugins/del_selective.py | 17 +++++++++++------ bot/plugins/del_to.py | 8 +++++--- bot/plugins/dmca_del.py | 8 ++++---- bot/plugins/help_text.py | 9 +++++++-- requirements.txt | 6 +++--- 9 files changed, 52 insertions(+), 43 deletions(-) diff --git a/app.json b/app.json index dec5335..e1f466b 100644 --- a/app.json +++ b/app.json @@ -32,11 +32,5 @@ "buildpacks": [{ "url": "heroku/python" }], - "formation": { - "worker": { - "quantity": 1, - "size": "free" - } - }, "stack": "heroku-20" } \ No newline at end of file diff --git a/bot/helpers/make_user_join_chat.py b/bot/helpers/make_user_join_chat.py index 093a36d..3b1e7fa 100644 --- a/bot/helpers/make_user_join_chat.py +++ b/bot/helpers/make_user_join_chat.py @@ -21,7 +21,10 @@ UserAlreadyParticipant ) from pyrogram.enums import ChatMemberStatus -from pyrogram.types import Message +from pyrogram.types import ( + Message, + ChatPrivileges +) from bot.bot import Bot @@ -44,15 +47,8 @@ async def make_chat_user_join( if not _existing_permissions.can_delete_messages: await message.chat.promote_member( user_id, - can_manage_chat=False, - can_change_info=False, - can_post_messages=False, - can_edit_messages=False, - can_delete_messages=True, - can_restrict_members=False, - can_invite_users=False, - can_pin_messages=False, - can_promote_members=False, - can_manage_voice_chats=False + ChatPrivileges( + can_delete_messages=True + ) ) return True, None diff --git a/bot/plugins/del_all.py b/bot/plugins/del_all.py index 59ff878..6c77d4c 100644 --- a/bot/plugins/del_all.py +++ b/bot/plugins/del_all.py @@ -19,7 +19,10 @@ ChatAdminRequired ) from pyrogram.raw.functions.channels import DeleteHistory -from pyrogram.types import Message +from pyrogram.types import ( + Message, + LinkPreviewOptions +) from bot import ( BEGINNING_DEL_ALL_MESSAGE, DEL_ALL_COMMAND, @@ -41,7 +44,7 @@ async def del_all_command_fn(client: Bot, message: Message): try: status_message = await message.reply_text( - BEGINNING_DEL_ALL_MESSAGE + text=BEGINNING_DEL_ALL_MESSAGE ) except ChatAdminRequired: status_message = None @@ -54,10 +57,12 @@ async def del_all_command_fn(client: Bot, message: Message): if not s__: if status_message: await status_message.edit_text( - IN_CORRECT_PERMISSIONS_MESSAGE.format( + text=IN_CORRECT_PERMISSIONS_MESSAGE.format( nop ), - disable_web_page_preview=True + link_preview_options=LinkPreviewOptions( + is_disabled=True + ), ) else: await message.delete() @@ -101,5 +106,5 @@ async def del_all_command_fn(client: Bot, message: Message): # after process is completed if status_message: await status_message.edit_text( - THANK_YOU_MESSAGE + text=THANK_YOU_MESSAGE ) diff --git a/bot/plugins/del_from.py b/bot/plugins/del_from.py index 454acf4..efa3c16 100644 --- a/bot/plugins/del_from.py +++ b/bot/plugins/del_from.py @@ -35,7 +35,7 @@ async def del_from_command_fn(client: Bot, message: Message): try: status_message = await message.reply_text( - "trying to save starting message_id" + text="trying to save starting message_id" ) except ChatAdminRequired: status_message = None @@ -48,8 +48,10 @@ async def del_from_command_fn(client: Bot, message: Message): ] = message.reply_to_message.id if status_message: await status_message.edit_text( - "saved starting message_id. " - "https://github.com/SpEcHiDe/DeleteMessagesRoBot" + text=( + "saved starting message_id. " + "https://github.com/SpEcHiDe/DeleteMessagesRoBot" + ) ) await status_message.delete() await message.delete() diff --git a/bot/plugins/del_selective.py b/bot/plugins/del_selective.py index 5c3b95c..962a19d 100644 --- a/bot/plugins/del_selective.py +++ b/bot/plugins/del_selective.py @@ -15,7 +15,10 @@ # along with this program. If not, see . from pyrogram import filters -from pyrogram.types import Message +from pyrogram.types import ( + Message, + LinkPreviewOptions +) from pyrogram.errors import ( ChatAdminRequired ) @@ -45,7 +48,7 @@ async def del_selective_command_fn(client: Bot, message: Message): try: status_message = await message.reply_text( - BEGINNING_SEL_DEL_MESSAGE + text=BEGINNING_SEL_DEL_MESSAGE ) except ChatAdminRequired: status_message = None @@ -58,10 +61,12 @@ async def del_selective_command_fn(client: Bot, message: Message): if not s__: if status_message: await status_message.edit_text( - IN_CORRECT_PERMISSIONS_MESSAGE.format( + text=IN_CORRECT_PERMISSIONS_MESSAGE.format( nop ), - disable_web_page_preview=True + link_preview_options=LinkPreviewOptions( + is_disabled=True + ), ) else: await message.delete() @@ -78,7 +83,7 @@ async def del_selective_command_fn(client: Bot, message: Message): current_selections = AKTIFPERINTAH.get(message.chat.id) if len(flt_type) == 0 and not current_selections: if status_message: - await status_message.edit(NOT_USED_DEL_FROM_DEL_TO_MESSAGE) + await status_message.edit(text=NOT_USED_DEL_FROM_DEL_TO_MESSAGE) else: await message.delete() return @@ -128,5 +133,5 @@ async def del_selective_command_fn(client: Bot, message: Message): # after process is completed if status_message: await status_message.edit_text( - THANK_YOU_MESSAGE + text=THANK_YOU_MESSAGE ) diff --git a/bot/plugins/del_to.py b/bot/plugins/del_to.py index 61e27b9..ac08cc8 100644 --- a/bot/plugins/del_to.py +++ b/bot/plugins/del_to.py @@ -35,7 +35,7 @@ async def del_to_command_fn(client: Bot, message: Message): try: status_message = await message.reply_text( - "trying to save ending message_id" + text="trying to save ending message_id" ) except ChatAdminRequired: status_message = None @@ -48,8 +48,10 @@ async def del_to_command_fn(client: Bot, message: Message): ] = message.reply_to_message.id if status_message: await status_message.edit_text( - "saved ending message_id. " - "https://github.com/SpEcHiDe/DeleteMessagesRoBot" + text=( + "saved ending message_id. " + "https://github.com/SpEcHiDe/DeleteMessagesRoBot" + ) ) await status_message.delete() await message.delete() diff --git a/bot/plugins/dmca_del.py b/bot/plugins/dmca_del.py index ad0e0fa..d936f02 100644 --- a/bot/plugins/dmca_del.py +++ b/bot/plugins/dmca_del.py @@ -47,9 +47,9 @@ ) ) async def dmca_spec_del_nf(client: Bot, message: Message): - bot_id = await client.get_me() + bot_id = client.me status_message = await message.reply_text( - BEGINNING_DEL_ALL_MESSAGE, + text=BEGINNING_DEL_ALL_MESSAGE, quote=True ) all_id_stores_ = knemblook(message) @@ -61,7 +61,7 @@ async def dmca_spec_del_nf(client: Bot, message: Message): qbo = check_perm(client, chat_id, bot_id) if not qbo: await status_message.reply_text( - IN_CORRECT_PERMISSIONS_MESSAGE, + text=IN_CORRECT_PERMISSIONS_MESSAGE, quote=True ) continue @@ -92,5 +92,5 @@ async def dmca_spec_del_nf(client: Bot, message: Message): await client.leave_chat(chat_id) await status_message.edit_text( - THANK_YOU_MESSAGE + text=THANK_YOU_MESSAGE ) diff --git a/bot/plugins/help_text.py b/bot/plugins/help_text.py index 59c6252..a3fdc0c 100644 --- a/bot/plugins/help_text.py +++ b/bot/plugins/help_text.py @@ -15,7 +15,10 @@ # along with this program. If not, see . from pyrogram import filters -from pyrogram.types import Message +from pyrogram.types import ( + Message, + LinkPreviewOptions +) from bot import ( START_COMMAND, START_MESSAGE @@ -31,6 +34,8 @@ async def start_command_fn(_, message: Message): await message.reply_text( text=START_MESSAGE, quote=True, - disable_web_page_preview=True, + link_preview_options=LinkPreviewOptions( + is_disabled=True + ), disable_notification=True ) diff --git a/requirements.txt b/requirements.txt index 8a98c3e..e069171 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -Pyrogram==2.0.35 -TgCrypto==1.2.3 +https://github.com/TelegramPlayGround/Pyrogram/archive/8079c1b.zip +TgCrypto==1.2.5 -python-dotenv>=0.10 +python-dotenv==0.10