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..e1f466b 100644
--- a/app.json
+++ b/app.json
@@ -26,18 +26,11 @@
"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": [
- {
- "url": "heroku/python"
- }
- ],
- "formation": {
- "worker": {
- "quantity": 1,
- "size": "free"
- }
- }
+ "buildpacks": [{
+ "url": "heroku/python"
+ }],
+ "stack": "heroku-20"
}
\ No newline at end of file
diff --git a/bot/__init__.py b/bot/__init__.py
index 1c60fe6..dea1d8c 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
@@ -50,6 +53,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 +83,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"
@@ -107,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/bot.py b/bot/bot.py
index fbaae1c..36f2442 100644
--- a/bot/bot.py
+++ b/bot/bot.py
@@ -20,45 +20,56 @@
Client,
__version__
)
+from pyrogram.enums import ParseMode
from . import (
API_HASH,
APP_ID,
LOGGER,
TG_BOT_SESSION,
TG_BOT_TOKEN,
- TG_BOT_WORKERS
+ TG_BOT_WORKERS,
+ TG_SLEEP_THRESHOLD
)
from .user import User
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
+ bot_token=TG_BOT_TOKEN,
+ 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/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
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
new file mode 100644
index 0000000..655a7c4
--- /dev/null
+++ b/bot/helpers/gulmnek.py
@@ -0,0 +1,50 @@
+#!/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 pyrogram.enums import MessageEntityType
+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:
+ _url = None
+ if one_entity.type == MessageEntityType.URL:
+ _url = text[
+ one_entity.offset:one_entity.offset + one_entity.length
+ ]
+ elif one_entity.type == MessageEntityType.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
diff --git a/bot/helpers/help_for_14121.py b/bot/helpers/help_for_14121.py
new file mode 100644
index 0000000..e99affb
--- /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
diff --git a/bot/helpers/make_user_join_chat.py b/bot/helpers/make_user_join_chat.py
index add6cc9..3b1e7fa 100644
--- a/bot/helpers/make_user_join_chat.py
+++ b/bot/helpers/make_user_join_chat.py
@@ -14,13 +14,17 @@
# 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.types import Message
+from pyrogram.enums import ChatMemberStatus
+from pyrogram.types import (
+ Message,
+ ChatPrivileges
+)
from bot.bot import Bot
@@ -36,19 +40,15 @@ 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":
- return True, None
+ if _existing_permissions.status == ChatMemberStatus.OWNER:
+ return True, 140
if not _existing_permissions.can_delete_messages:
await message.chat.promote_member(
user_id,
- 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
+ ChatPrivileges(
+ can_delete_messages=True
+ )
)
return True, None
diff --git a/bot/plugins/del_all.py b/bot/plugins/del_all.py
index 1381cb8..6c77d4c 100644
--- a/bot/plugins/del_all.py
+++ b/bot/plugins/del_all.py
@@ -15,14 +15,21 @@
# 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,
+ LinkPreviewOptions
+)
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,
+ THANK_YOU_MESSAGE
)
from bot.bot import Bot
from bot.helpers.custom_filter import allowed_chat_filter
@@ -37,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
@@ -50,23 +57,54 @@ 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()
return
- await get_messages(
- client.USER,
- message.chat.id,
- 0,
- status_message.message_id if status_message else message.message_id,
- []
- )
+ 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
+ )
+ )
+
+ 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
- await client.USER.leave_chat(message.chat.id)
- await client.leave_chat(message.chat.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
+ if status_message:
+ await status_message.edit_text(
+ text=THANK_YOU_MESSAGE
+ )
diff --git a/bot/plugins/del_from.py b/bot/plugins/del_from.py
index aafbe3d..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
@@ -45,11 +45,13 @@ 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. "
- "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 51621a9..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
)
@@ -27,6 +30,9 @@
IN_CORRECT_PERMISSIONS_MESSAGE,
NOT_USED_DEL_FROM_DEL_TO_MESSAGE,
SEL_DEL_COMMAND,
+ SHTL_BOT_HCAT_QO,
+ SHTL_USR_HCAT_QO,
+ THANK_YOU_MESSAGE,
TL_FILE_TYPES
)
from bot.bot import Bot
@@ -42,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
@@ -55,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()
@@ -75,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
@@ -91,7 +99,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,
@@ -104,8 +113,9 @@ 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:
+ except: # noqa: E722
pass
try:
@@ -114,5 +124,14 @@ 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)
+
+ # edit with channel message ads,
+ # after process is completed
+ if status_message:
+ await status_message.edit_text(
+ text=THANK_YOU_MESSAGE
+ )
diff --git a/bot/plugins/del_to.py b/bot/plugins/del_to.py
index c449288..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
@@ -45,11 +45,13 @@ 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. "
- "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
new file mode 100644
index 0000000..d936f02
--- /dev/null
+++ b/bot/plugins/dmca_del.py
@@ -0,0 +1,96 @@
+#!/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 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 = client.me
+ status_message = await message.reply_text(
+ 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(
+ 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(
+ 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/bot/user.py b/bot/user.py
index 30b269c..79d1624 100644
--- a/bot/user.py
+++ b/bot/user.py
@@ -20,11 +20,13 @@
Client,
__version__
)
+from pyrogram.enums import ParseMode
from . import (
API_HASH,
APP_ID,
LOGGER,
TG_BOT_WORKERS,
+ TG_SLEEP_THRESHOLD,
TG_USER_SESSION
)
@@ -34,22 +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
+ workers=TG_BOT_WORKERS,
+ 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 2d50347..e069171 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,4 +1,4 @@
-Pyrogram==1.0.7
-TgCrypto==1.2.1
+https://github.com/TelegramPlayGround/Pyrogram/archive/8079c1b.zip
+TgCrypto==1.2.5
-python-dotenv>=0.10
+python-dotenv==0.10
diff --git a/runtime.txt b/runtime.txt
index 1124509..d667043 100644
--- a/runtime.txt
+++ b/runtime.txt
@@ -1 +1 @@
-python-3.8.5
\ No newline at end of file
+python-3.9.7
\ No newline at end of file
diff --git a/sample_config.env b/sample_config.env
index 5b4d5e7..5d655ac 100644
--- a/sample_config.env
+++ b/sample_config.env
@@ -22,9 +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=
# ----------- CUSTOM STRINGS ----------- #
@@ -33,6 +36,7 @@
# IN_CORRECT_PERMISSIONS_MESSAGE=
# BEGINNING_SEL_DEL_MESSAGE=
# NOT_USED_DEL_FROM_DEL_TO_MESSAGE=
+# THANK_YOU_MESSAGE=
# ----------- CUSTOM COMMANDS ----------- #