From ac0053e6667c69b7451da7accdfaa492debd1aeb Mon Sep 17 00:00:00 2001 From: Ujjwalm2004 <130154620+Ujjwalm2004@users.noreply.github.com> Date: Mon, 1 May 2023 20:34:37 +0530 Subject: [PATCH 01/33] Rename send_file.py to send_file_.py --- handlers/{send_file.py => send_file_.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename handlers/{send_file.py => send_file_.py} (100%) diff --git a/handlers/send_file.py b/handlers/send_file_.py similarity index 100% rename from handlers/send_file.py rename to handlers/send_file_.py From be8feb01235ea145db7748a4e65440cf5aa14ee7 Mon Sep 17 00:00:00 2001 From: Ujjwalm2004 <130154620+Ujjwalm2004@users.noreply.github.com> Date: Mon, 1 May 2023 20:35:15 +0530 Subject: [PATCH 02/33] .. --- handlers/send_file.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 handlers/send_file.py diff --git a/handlers/send_file.py b/handlers/send_file.py new file mode 100644 index 0000000..92988be --- /dev/null +++ b/handlers/send_file.py @@ -0,0 +1,40 @@ +#@MxA_Bots | @iSmartBoi_Ujjwal + +import asyncio +from configs import Config +from pyrogram import Client +from pyrogram.types import Message +from pyrogram.errors import FloodWait +from handlers.helpers import str_to_b64 + +async def reply_forward(message: Message, file_id: int): + try: + await message.reply_text( + f"**Files will be Deleted After 1 min**\n" + f"๐Ÿ’กForward it to saved massages or anywhere before downloading.๐Ÿ˜\n" + f"๐Ÿ˜‡Join @Movies_X_Animes", + disable_web_page_preview=True, quote=True) + except FloodWait as e: + await asyncio.sleep(e.value) + await reply_forward(message, file_id) + + +async def media_forward(bot: Client, user_id: int, file_id: int): + try: + if Config.FORWARD_AS_COPY is True: + return await bot.copy_message(chat_id=user_id, from_chat_id=Config.DB_CHANNEL, + message_id=file_id) + + elif Config.FORWARD_AS_COPY is False: + return await bot.forward_messages(chat_id=user_id, from_chat_id=Config.DB_CHANNEL, + message_ids=file_id) + except FloodWait as e: + await asyncio.sleep(e.value) + return media_forward(bot, user_id, file_id) + + +async def send_media_and_reply(bot: Client, user_id: int, file_id: int): + sent_message = await media_forward(bot, user_id, file_id) + await reply_forward(message=sent_message, file_id=file_id) + await asyncio.sleep(60) + await sent_message.delete() From 6692626b4741e399592a23557959cbf36df91f2f Mon Sep 17 00:00:00 2001 From: Ujjwalm2004 <130154620+Ujjwalm2004@users.noreply.github.com> Date: Mon, 1 May 2023 20:35:46 +0530 Subject: [PATCH 03/33] Delete send_file_.py --- handlers/send_file_.py | 44 ------------------------------------------ 1 file changed, 44 deletions(-) delete mode 100644 handlers/send_file_.py diff --git a/handlers/send_file_.py b/handlers/send_file_.py deleted file mode 100644 index ef3b6db..0000000 --- a/handlers/send_file_.py +++ /dev/null @@ -1,44 +0,0 @@ -#@MxA_Bots | @iSmartBoi_Ujjwal - -import asyncio -from configs import Config -from pyrogram import Client -from pyrogram.types import Message -from pyrogram.errors import FloodWait -from handlers.helpers import str_to_b64 - - -async def reply_forward(message: Message, file_id: int): - try: - await message.reply_text( - f"**Files will be Deleted After few seconds โฐ**\n", - disable_web_page_preview=True, quote=True) - except FloodWait as e: - await asyncio.sleep(e.value) - await reply_forward(message, file_id) - - -async def media_forward(bot: Client, user_id: int, file_id: int): - try: - if Config.FORWARD_AS_COPY is True: - return await bot.copy_message(chat_id=user_id, from_chat_id=Config.DB_CHANNEL, - message_id=file_id) - elif Config.FORWARD_AS_COPY is False: - return await bot.forward_messages(chat_id=user_id, from_chat_id=Config.DB_CHANNEL, - message_ids=file_id) - except FloodWait as e: - await asyncio.sleep(e.value) - return media_forward(bot, user_id, file_id) - - -async def delete_file(file_id: int): - await asyncio.sleep(50) # wait for 50 seconds - # Delete the file using the file ID - # Code to delete the file goes here - - -async def send_media_and_reply(bot: Client, user_id: int, file_id: int): - sent_message = await media_forward(bot, user_id, file_id) - await reply_forward(message=sent_message, file_id=file_id) - asyncio.create_task(delete_file(file_id)) # schedule the file deletion task - await asyncio.sleep(2) From 39f8c1780775c8e9b6404d22e19956f8724322f0 Mon Sep 17 00:00:00 2001 From: Ujjwalm2004 <130154620+Ujjwalm2004@users.noreply.github.com> Date: Mon, 1 May 2023 20:36:46 +0530 Subject: [PATCH 04/33] Update send_file.py --- handlers/send_file.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/handlers/send_file.py b/handlers/send_file.py index 92988be..16fd2fb 100644 --- a/handlers/send_file.py +++ b/handlers/send_file.py @@ -35,6 +35,8 @@ async def media_forward(bot: Client, user_id: int, file_id: int): async def send_media_and_reply(bot: Client, user_id: int, file_id: int): sent_message = await media_forward(bot, user_id, file_id) - await reply_forward(message=sent_message, file_id=file_id) + n = await reply_forward(message=sent_message, file_id=file_id) await asyncio.sleep(60) await sent_message.delete() + await asyncio.sleep(0.5) + await n.delete() From c434a3ae0759307f978fef0f31bd3980d5357bb0 Mon Sep 17 00:00:00 2001 From: Ujjwalm2004 <130154620+Ujjwalm2004@users.noreply.github.com> Date: Mon, 1 May 2023 20:38:09 +0530 Subject: [PATCH 05/33] Update send_file.py --- handlers/send_file.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/handlers/send_file.py b/handlers/send_file.py index 16fd2fb..0eae20b 100644 --- a/handlers/send_file.py +++ b/handlers/send_file.py @@ -36,7 +36,7 @@ async def media_forward(bot: Client, user_id: int, file_id: int): async def send_media_and_reply(bot: Client, user_id: int, file_id: int): sent_message = await media_forward(bot, user_id, file_id) n = await reply_forward(message=sent_message, file_id=file_id) - await asyncio.sleep(60) + await asyncio.sleep(30) await sent_message.delete() await asyncio.sleep(0.5) await n.delete() From 0b0e4981e022b68ca6460cf6ec0aa1c2f3d297b3 Mon Sep 17 00:00:00 2001 From: Ujjwalm2004 <130154620+Ujjwalm2004@users.noreply.github.com> Date: Tue, 2 May 2023 12:20:37 +0530 Subject: [PATCH 06/33] Update send_file.py --- handlers/send_file.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/handlers/send_file.py b/handlers/send_file.py index 0eae20b..4304553 100644 --- a/handlers/send_file.py +++ b/handlers/send_file.py @@ -35,8 +35,10 @@ async def media_forward(bot: Client, user_id: int, file_id: int): async def send_media_and_reply(bot: Client, user_id: int, file_id: int): sent_message = await media_forward(bot, user_id, file_id) - n = await reply_forward(message=sent_message, file_id=file_id) - await asyncio.sleep(30) - await sent_message.delete() - await asyncio.sleep(0.5) - await n.delete() + await asyncio.sleep(1) + return sent_message + # n = await reply_forward(message=sent_message, file_id=file_id) + # await asyncio.sleep(30) + # await sent_message.delete() + # await asyncio.sleep(0.5) + # await n.delete() From e8f76b3a7dd1664631e94a7c48f1ce596efacaa6 Mon Sep 17 00:00:00 2001 From: Ujjwalm2004 <130154620+Ujjwalm2004@users.noreply.github.com> Date: Wed, 3 May 2023 14:43:21 +0530 Subject: [PATCH 07/33] Update send_file.py --- handlers/send_file.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/handlers/send_file.py b/handlers/send_file.py index 4304553..7d3aa7c 100644 --- a/handlers/send_file.py +++ b/handlers/send_file.py @@ -1,5 +1,7 @@ #@MxA_Bots | @iSmartBoi_Ujjwal +import os +from os import environ import asyncio from configs import Config from pyrogram import Client @@ -7,12 +9,13 @@ from pyrogram.errors import FloodWait from handlers.helpers import str_to_b64 +DELETE_TIME = int(environ.get("DELETE_TIME")) +AUTODELETE_MESSAGE = os.getenv("from os import environ", '''โ€ผ๏ธ File will auto delete in few seconds๐Ÿ˜ฑ ๐Ÿ’กForward it to saved massages or anywhere before downloading.๐Ÿ˜ ๐Ÿ˜‡Join @Movies_X_Animes''') + async def reply_forward(message: Message, file_id: int): try: await message.reply_text( - f"**Files will be Deleted After 1 min**\n" - f"๐Ÿ’กForward it to saved massages or anywhere before downloading.๐Ÿ˜\n" - f"๐Ÿ˜‡Join @Movies_X_Animes", + f"AUTODELETE_MESSAGE", disable_web_page_preview=True, quote=True) except FloodWait as e: await asyncio.sleep(e.value) @@ -35,9 +38,11 @@ async def media_forward(bot: Client, user_id: int, file_id: int): async def send_media_and_reply(bot: Client, user_id: int, file_id: int): sent_message = await media_forward(bot, user_id, file_id) - await asyncio.sleep(1) - return sent_message - # n = await reply_forward(message=sent_message, file_id=file_id) + await message.reply_text(f'AUTODELETE_MESSAGE') + asyncio.sleep(DELETE_TIME) + await sent_message.delete() + # return sent_message + # n = # await asyncio.sleep(30) # await sent_message.delete() # await asyncio.sleep(0.5) From f3c8c59fddde6309b022d0c1573d40d2fb730e41 Mon Sep 17 00:00:00 2001 From: Ujjwalm2004 <130154620+Ujjwalm2004@users.noreply.github.com> Date: Thu, 4 May 2023 11:54:49 +0530 Subject: [PATCH 08/33] Update send_file.py --- handlers/send_file.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/handlers/send_file.py b/handlers/send_file.py index 7d3aa7c..ad34c84 100644 --- a/handlers/send_file.py +++ b/handlers/send_file.py @@ -41,9 +41,3 @@ async def send_media_and_reply(bot: Client, user_id: int, file_id: int): await message.reply_text(f'AUTODELETE_MESSAGE') asyncio.sleep(DELETE_TIME) await sent_message.delete() - # return sent_message - # n = - # await asyncio.sleep(30) - # await sent_message.delete() - # await asyncio.sleep(0.5) - # await n.delete() From 60d84a231ffbb5a307de01f0f79092bd297eeb38 Mon Sep 17 00:00:00 2001 From: Ujjwalm2004 <130154620+Ujjwalm2004@users.noreply.github.com> Date: Thu, 4 May 2023 12:00:58 +0530 Subject: [PATCH 09/33] Update configs.py --- configs.py | 1 + 1 file changed, 1 insertion(+) diff --git a/configs.py b/configs.py index ccd03af..fa61189 100644 --- a/configs.py +++ b/configs.py @@ -8,6 +8,7 @@ class Config(object): API_HASH = os.environ.get("API_HASH") BOT_TOKEN = os.environ.get("BOT_TOKEN") BOT_USERNAME = os.environ.get("BOT_USERNAME") + DB_CHANNEL = int(os.environ.get("DB_CHANNEL", "-100")) BOT_OWNER = int(os.environ.get("BOT_OWNER", "1445283714")) DATABASE_URL = os.environ.get("DATABASE_URL") From 01bd19c63cbb9b13eb547f24abc03aed200c5a86 Mon Sep 17 00:00:00 2001 From: Ujjwalm2004 <130154620+Ujjwalm2004@users.noreply.github.com> Date: Thu, 4 May 2023 12:05:24 +0530 Subject: [PATCH 10/33] Update configs.py --- configs.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/configs.py b/configs.py index fa61189..8235215 100644 --- a/configs.py +++ b/configs.py @@ -7,8 +7,7 @@ class Config(object): API_ID = int(os.environ.get("API_ID", "0")) API_HASH = os.environ.get("API_HASH") BOT_TOKEN = os.environ.get("BOT_TOKEN") - BOT_USERNAME = os.environ.get("BOT_USERNAME") - + BOT_USERNAME = os.environ.get("BOT_USERNAME") DB_CHANNEL = int(os.environ.get("DB_CHANNEL", "-100")) BOT_OWNER = int(os.environ.get("BOT_OWNER", "1445283714")) DATABASE_URL = os.environ.get("DATABASE_URL") From 4922a161a35fe2ab92d701bd5f3e236a7b42d5f8 Mon Sep 17 00:00:00 2001 From: Ujjwalm2004 <130154620+Ujjwalm2004@users.noreply.github.com> Date: Thu, 4 May 2023 12:10:50 +0530 Subject: [PATCH 11/33] Update configs.py --- configs.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/configs.py b/configs.py index 8235215..d0190d2 100644 --- a/configs.py +++ b/configs.py @@ -11,11 +11,12 @@ class Config(object): DB_CHANNEL = int(os.environ.get("DB_CHANNEL", "-100")) BOT_OWNER = int(os.environ.get("BOT_OWNER", "1445283714")) DATABASE_URL = os.environ.get("DATABASE_URL") - UPDATES_CHANNEL = os.environ.get("UPDATES_CHANNEL", "") + UPDATES_CHANNEL = os.environ.get("UPDATES_CHANNEL", "") + UPDATES_CHANNEL_USERNAME = os.environ.get("UPDATES_CHANNEL_USERNAME", "") LOG_CHANNEL = os.environ.get("LOG_CHANNEL", None) BANNED_USERS = set(int(x) for x in os.environ.get("BANNED_USERS", "1234567890").split()) FORWARD_AS_COPY = bool(os.environ.get("FORWARD_AS_COPY", True)) - BROADCAST_AS_COPY = bool(os.environ.get("BROADCAST_AS_COPY", False)) + BROADCAST_AS_COPY = bool(os.environ.get("BROADCAST_AS_COPY", True)) BANNED_CHAT_IDS = list(set(int(x) for x in os.environ.get("BANNED_CHAT_IDS", "-1001362659779 -1001255795497").split())) OTHER_USERS_CAN_SAVE_FILE = bool(os.environ.get("OTHER_USERS_CAN_SAVE_FILE", True)) ABOUT_BOT_TEXT = f"""This is a Permanent FileStore Bot. @@ -42,9 +43,8 @@ class Config(object): ๐€๐ฅ๐ฌ๐จ ๐ซ๐ž๐ฆ๐ž๐ฆ๐›๐ž๐ซ ๐ญ๐ก๐š๐ญ ๐๐ž๐ฏ๐ž๐ฅ๐จ๐ฉ๐ž๐ซ ๐ฐ๐ข๐ฅ๐ฅ ๐ƒ๐ž๐ฅ๐ž๐ญ๐ž ๐€๐๐ฎ๐ฅ๐ญ ๐‚๐จ๐ง๐ญ๐ž๐ง๐ญ๐ฌ ๐Ÿ๐ซ๐จ๐ฆ ๐ƒ๐š๐ญ๐š๐›๐š๐ฌ๐ž. ๐’๐จ ๐›๐ž๐ญ๐ญ๐ž๐ซ ๐๐จ๐ง'๐ญ ๐’๐ญ๐จ๐ซ๐ž ๐“๐ก๐จ๐ฌ๐ž ๐Š๐ข๐ง๐ ๐จ๐Ÿ ๐“๐ก๐ข๐ง๐ ๐ฌ. ๐‰๐จ๐ข๐ง **@MxA_Bots** """ + HOME_TEXT = HOME_TEXT = """ -Hello, [{}](tg://user?id={})\n\nThis is a Permanent **FษชสŸแด‡Sแด›แดส€แด‡Bแดแด›**. -๐Ÿ“ข Send me any File & It will be uploaded in My Database & You will Get the File Link. -โš ๏ธ Benefits: If you have a TeleGram Movie Channel or Any Copyright Channel, Then Its Useful for Daily Usage, You can Send Me Your File & I will Send Permanent Link to You & Channel will be Safe from **CopyRight Infringement** Issue. I support Channel Also You Can Check **About Bot**. -โŒ **PORNOGRAPHY CONTENTS** are strictly prohibited & get Permanent Ban. +Hello, [{}](tg://user?id={})\n\nThis is a Permanent **FษชสŸแด‡Sแด›แดส€แด‡Bแดแด›** Made for @UPDATES_CHANNEL_USERNAME """ + From d1bb768ed37c814a9cae309ed3264880eb39abd6 Mon Sep 17 00:00:00 2001 From: Ujjwalm2004 <130154620+Ujjwalm2004@users.noreply.github.com> Date: Thu, 4 May 2023 12:12:24 +0530 Subject: [PATCH 12/33] Update send_file.py --- handlers/send_file.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/handlers/send_file.py b/handlers/send_file.py index ad34c84..2ae7975 100644 --- a/handlers/send_file.py +++ b/handlers/send_file.py @@ -10,7 +10,7 @@ from handlers.helpers import str_to_b64 DELETE_TIME = int(environ.get("DELETE_TIME")) -AUTODELETE_MESSAGE = os.getenv("from os import environ", '''โ€ผ๏ธ File will auto delete in few seconds๐Ÿ˜ฑ ๐Ÿ’กForward it to saved massages or anywhere before downloading.๐Ÿ˜ ๐Ÿ˜‡Join @Movies_X_Animes''') +AUTODELETE_MESSAGE = os.getenv("from os import environ", '''โ€ผ๏ธ File will auto delete in few seconds๐Ÿ˜ฑ ๐Ÿ’กForward it to saved massages or anywhere before downloading.๐Ÿ˜ ๐Ÿ˜‡Join @(UPDATES_CHANNEL_USERNAME)''') async def reply_forward(message: Message, file_id: int): try: From 662b233761fae5677016e96167fea6707d11a8ab Mon Sep 17 00:00:00 2001 From: Ujjwalm2004 <130154620+Ujjwalm2004@users.noreply.github.com> Date: Thu, 4 May 2023 12:12:48 +0530 Subject: [PATCH 13/33] Update send_file.py --- handlers/send_file.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/handlers/send_file.py b/handlers/send_file.py index 2ae7975..278d3ee 100644 --- a/handlers/send_file.py +++ b/handlers/send_file.py @@ -15,7 +15,7 @@ async def reply_forward(message: Message, file_id: int): try: await message.reply_text( - f"AUTODELETE_MESSAGE", + f"(AUTODELETE_MESSAGE)", disable_web_page_preview=True, quote=True) except FloodWait as e: await asyncio.sleep(e.value) From cf977836b9b35baa9ac5d4595a30c5e1210ba8b1 Mon Sep 17 00:00:00 2001 From: Ujjwalm2004 <130154620+Ujjwalm2004@users.noreply.github.com> Date: Thu, 4 May 2023 12:14:26 +0530 Subject: [PATCH 14/33] Update send_file.py --- handlers/send_file.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/handlers/send_file.py b/handlers/send_file.py index 278d3ee..ca836ec 100644 --- a/handlers/send_file.py +++ b/handlers/send_file.py @@ -10,12 +10,12 @@ from handlers.helpers import str_to_b64 DELETE_TIME = int(environ.get("DELETE_TIME")) -AUTODELETE_MESSAGE = os.getenv("from os import environ", '''โ€ผ๏ธ File will auto delete in few seconds๐Ÿ˜ฑ ๐Ÿ’กForward it to saved massages or anywhere before downloading.๐Ÿ˜ ๐Ÿ˜‡Join @(UPDATES_CHANNEL_USERNAME)''') +AUTODELETE_MESSAGE = os.getenv("from os import environ", '''โ€ผ๏ธ File will auto delete in few seconds๐Ÿ˜ฑ ๐Ÿ’กForward it to saved massages or anywhere before downloading.๐Ÿ˜ ๐Ÿ˜‡Join @{UPDATES_CHANNEL_USERNAME}''') async def reply_forward(message: Message, file_id: int): try: await message.reply_text( - f"(AUTODELETE_MESSAGE)", + f"{AUTODELETE_MESSAGE}", disable_web_page_preview=True, quote=True) except FloodWait as e: await asyncio.sleep(e.value) @@ -38,6 +38,6 @@ async def media_forward(bot: Client, user_id: int, file_id: int): async def send_media_and_reply(bot: Client, user_id: int, file_id: int): sent_message = await media_forward(bot, user_id, file_id) - await message.reply_text(f'AUTODELETE_MESSAGE') + await message.reply_text(f'{AUTODELETE_MESSAGE}') asyncio.sleep(DELETE_TIME) await sent_message.delete() From 3c1dbd1ac84377cadc1ecce9b6b44b28ff343900 Mon Sep 17 00:00:00 2001 From: Ujjwalm2004 <130154620+Ujjwalm2004@users.noreply.github.com> Date: Thu, 4 May 2023 12:15:09 +0530 Subject: [PATCH 15/33] Update configs.py --- configs.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/configs.py b/configs.py index d0190d2..a986ac5 100644 --- a/configs.py +++ b/configs.py @@ -45,6 +45,7 @@ class Config(object): """ HOME_TEXT = HOME_TEXT = """ -Hello, [{}](tg://user?id={})\n\nThis is a Permanent **FษชสŸแด‡Sแด›แดส€แด‡Bแดแด›** Made for @UPDATES_CHANNEL_USERNAME +Hello, [{}](tg://user?id={})\n\nThis is a Permanent **FษชสŸแด‡Sแด›แดส€แด‡Bแดแด›** Made for @{UPDATES_CHANNEL_USERNAME} """ + From ce471006a2b82c17f38925e0269b7d2d4998a229 Mon Sep 17 00:00:00 2001 From: Ujjwalm2004 <130154620+Ujjwalm2004@users.noreply.github.com> Date: Tue, 9 May 2023 20:00:35 +0530 Subject: [PATCH 16/33] Update configs.py --- configs.py | 1 - 1 file changed, 1 deletion(-) diff --git a/configs.py b/configs.py index a986ac5..541c525 100644 --- a/configs.py +++ b/configs.py @@ -43,7 +43,6 @@ class Config(object): ๐€๐ฅ๐ฌ๐จ ๐ซ๐ž๐ฆ๐ž๐ฆ๐›๐ž๐ซ ๐ญ๐ก๐š๐ญ ๐๐ž๐ฏ๐ž๐ฅ๐จ๐ฉ๐ž๐ซ ๐ฐ๐ข๐ฅ๐ฅ ๐ƒ๐ž๐ฅ๐ž๐ญ๐ž ๐€๐๐ฎ๐ฅ๐ญ ๐‚๐จ๐ง๐ญ๐ž๐ง๐ญ๐ฌ ๐Ÿ๐ซ๐จ๐ฆ ๐ƒ๐š๐ญ๐š๐›๐š๐ฌ๐ž. ๐’๐จ ๐›๐ž๐ญ๐ญ๐ž๐ซ ๐๐จ๐ง'๐ญ ๐’๐ญ๐จ๐ซ๐ž ๐“๐ก๐จ๐ฌ๐ž ๐Š๐ข๐ง๐ ๐จ๐Ÿ ๐“๐ก๐ข๐ง๐ ๐ฌ. ๐‰๐จ๐ข๐ง **@MxA_Bots** """ - HOME_TEXT = HOME_TEXT = """ Hello, [{}](tg://user?id={})\n\nThis is a Permanent **FษชสŸแด‡Sแด›แดส€แด‡Bแดแด›** Made for @{UPDATES_CHANNEL_USERNAME} """ From f356061d1aea80e9050d5f583f0d4cf49c98e8da Mon Sep 17 00:00:00 2001 From: Ujjwalm2004 <130154620+Ujjwalm2004@users.noreply.github.com> Date: Sun, 14 Apr 2024 16:35:45 +0530 Subject: [PATCH 17/33] Update configs.py --- configs.py | 1 + 1 file changed, 1 insertion(+) diff --git a/configs.py b/configs.py index 541c525..80f9f5b 100644 --- a/configs.py +++ b/configs.py @@ -4,6 +4,7 @@ class Config(object): + URL = os.getenv("URL", "") API_ID = int(os.environ.get("API_ID", "0")) API_HASH = os.environ.get("API_HASH") BOT_TOKEN = os.environ.get("BOT_TOKEN") From 8ad2b48af4426ee272227d9eb992504b7bfcf485 Mon Sep 17 00:00:00 2001 From: Ujjwalm2004 <130154620+Ujjwalm2004@users.noreply.github.com> Date: Sun, 14 Apr 2024 16:37:03 +0530 Subject: [PATCH 18/33] Create server.py --- server.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 server.py diff --git a/server.py b/server.py new file mode 100644 index 0000000..52c7f28 --- /dev/null +++ b/server.py @@ -0,0 +1,28 @@ +from aiohttp import web +import asyncio, logging, aiohttp, traceback +from configs import URL + +r = web.RouteTableDef() + +@r.get("/", allow_head=True) +async def root_route_handler(request): + return web.json_response("I am Alive") + +async def web_server(): + wap = web.Application(client_max_size=30000000) + wap.add_routes(r) + return wap + +async def ping_server(): + while True: + await asyncio.sleep(600) + try: + async with aiohttp.ClientSession( + timeout=aiohttp.ClientTimeout(total=10) + ) as session: + async with session.get(URL) as resp: + logging.info("Pinged server with response: {}".format(resp.status)) + except TimeoutError: + logging.warning("Couldn't connect to the site URL..!") + except Exception: + traceback.print_exc() From 58953a5d8338230e7d4cf9edc13a721e6dff020b Mon Sep 17 00:00:00 2001 From: Ujjwalm2004 <130154620+Ujjwalm2004@users.noreply.github.com> Date: Sun, 14 Apr 2024 16:40:00 +0530 Subject: [PATCH 19/33] Update bot.py --- bot.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/bot.py b/bot.py index 79771c4..c6a38a3 100644 --- a/bot.py +++ b/bot.py @@ -37,6 +37,8 @@ save_media_in_channel, save_batch_media_in_channel ) +from server import web_server, ping_server +from aiohttp import web MediaList = {} @@ -467,5 +469,11 @@ async def button(bot: Client, cmd: CallbackQuery): await cmd.answer() except QueryIdInvalid: pass - -Bot.run() +if __name__ == '__main__': + wapp = web.AppRunner(await web_server()) + await wapp.setup() + ba = "0.0.0.0" + port = int(os.getenv("PORT", 8080)) + await web.TCPSite(wapp, ba, port).start() + asyncio.create_task(ping_server()) + Bot.run() From 231e2d0ff293b5525565447a2e7f332a29216351 Mon Sep 17 00:00:00 2001 From: Ujjwalm2004 <130154620+Ujjwalm2004@users.noreply.github.com> Date: Sun, 14 Apr 2024 16:40:42 +0530 Subject: [PATCH 20/33] Update requirements.txt --- requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 14f35df..f717d22 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ -Pyrogram==2.0.30 +Pyrogram==2.0.106 TgCrypto motor aiofiles dnspython psutil -aiohttp \ No newline at end of file +aiohttp From a06ee3cf41d614a85a8b126afcf6e25f0ec010a7 Mon Sep 17 00:00:00 2001 From: Ujjwalm2004 <130154620+Ujjwalm2004@users.noreply.github.com> Date: Sun, 14 Apr 2024 16:41:38 +0530 Subject: [PATCH 21/33] Update Procfile --- Procfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Procfile b/Procfile index a561093..a18caa2 100644 --- a/Procfile +++ b/Procfile @@ -1 +1 @@ -worker: python3 bot.py \ No newline at end of file +web: python3 bot.py From c8a6e24dbd60a9e3530ed5dada35a68d999df561 Mon Sep 17 00:00:00 2001 From: Ujjwalm2004 <130154620+Ujjwalm2004@users.noreply.github.com> Date: Sun, 14 Apr 2024 17:02:46 +0530 Subject: [PATCH 22/33] Update Dockerfile --- Dockerfile | 34 ++++++---------------------------- 1 file changed, 6 insertions(+), 28 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0222be4..ca4a7d1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,33 +1,11 @@ -FROM ubuntu:18.04 +FROM python:3.8-slim-buster -ENV DEBIAN_FRONTEND=noninteractive -RUN apt-get update -RUN echo y | apt-get install locales -RUN echo y | apt install build-essential -RUN apt -qq install -y --no-install-recommends \ - curl \ - git \ - gnupg2 \ - wget \ +WORKDIR /app -RUN set -ex; \ - apt-get update \ - && apt-get install -y --no-install-recommends \ - busybox \ - git \ - python3 \ - python3-dev \ - python3-pip \ - python3-lxml \ - pv \ - && apt-get autoclean \ - && apt-get autoremove \ - && rm -rf /var/lib/apt/lists/* - -RUN pip3 install setuptools wheel yarl multidict COPY requirements.txt . -RUN pip3 install -r requirements.txt -RUN dpkg-reconfigure locales -COPY . /app + +RUN pip install --no-cache-dir -r requirements.txt + +COPY . . CMD ["python3", "bot.py"] From 292de8a0ca961d0080eef2cbf82ec7545f2d86b1 Mon Sep 17 00:00:00 2001 From: Ujjwalm2004 <130154620+Ujjwalm2004@users.noreply.github.com> Date: Sun, 14 Apr 2024 17:15:06 +0530 Subject: [PATCH 23/33] Update bot.py --- bot.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bot.py b/bot.py index c6a38a3..e0f98c9 100644 --- a/bot.py +++ b/bot.py @@ -469,11 +469,15 @@ async def button(bot: Client, cmd: CallbackQuery): await cmd.answer() except QueryIdInvalid: pass -if __name__ == '__main__': +async def main(): wapp = web.AppRunner(await web_server()) await wapp.setup() ba = "0.0.0.0" port = int(os.getenv("PORT", 8080)) await web.TCPSite(wapp, ba, port).start() + await Bot.run() asyncio.create_task(ping_server()) - Bot.run() + + +if __name__ == '__main__': + asyncio.run(main()) From c51e669f8333996b3a99739e9629697ce42caf24 Mon Sep 17 00:00:00 2001 From: Ujjwalm2004 <130154620+Ujjwalm2004@users.noreply.github.com> Date: Sun, 14 Apr 2024 17:51:14 +0530 Subject: [PATCH 24/33] Update send_file.py --- handlers/send_file.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/handlers/send_file.py b/handlers/send_file.py index ca836ec..637df84 100644 --- a/handlers/send_file.py +++ b/handlers/send_file.py @@ -9,7 +9,7 @@ from pyrogram.errors import FloodWait from handlers.helpers import str_to_b64 -DELETE_TIME = int(environ.get("DELETE_TIME")) +DELETE_TIME = int(environ.get("DELETE_TIME", "3600")) AUTODELETE_MESSAGE = os.getenv("from os import environ", '''โ€ผ๏ธ File will auto delete in few seconds๐Ÿ˜ฑ ๐Ÿ’กForward it to saved massages or anywhere before downloading.๐Ÿ˜ ๐Ÿ˜‡Join @{UPDATES_CHANNEL_USERNAME}''') async def reply_forward(message: Message, file_id: int): From 6ca834e04502c53e45815464fdfac48024a4aac7 Mon Sep 17 00:00:00 2001 From: Ujjwalm2004 <130154620+Ujjwalm2004@users.noreply.github.com> Date: Sun, 14 Apr 2024 17:52:07 +0530 Subject: [PATCH 25/33] Update send_file.py --- handlers/send_file.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/handlers/send_file.py b/handlers/send_file.py index 637df84..d8bef4b 100644 --- a/handlers/send_file.py +++ b/handlers/send_file.py @@ -10,7 +10,7 @@ from handlers.helpers import str_to_b64 DELETE_TIME = int(environ.get("DELETE_TIME", "3600")) -AUTODELETE_MESSAGE = os.getenv("from os import environ", '''โ€ผ๏ธ File will auto delete in few seconds๐Ÿ˜ฑ ๐Ÿ’กForward it to saved massages or anywhere before downloading.๐Ÿ˜ ๐Ÿ˜‡Join @{UPDATES_CHANNEL_USERNAME}''') +AUTODELETE_MESSAGE = os.getenv("AUTODELETE_MESSAGE", '''โ€ผ๏ธ File will auto delete in few seconds๐Ÿ˜ฑ\n๐Ÿ’กForward it to saved massages or anywhere before downloading.๐Ÿ˜\n๐Ÿ˜‡Join @{UPDATES_CHANNEL_USERNAME}''') async def reply_forward(message: Message, file_id: int): try: From 95a01f802da87ef6515e36aff558092ad85d1bf1 Mon Sep 17 00:00:00 2001 From: Ujjwalm2004 <130154620+Ujjwalm2004@users.noreply.github.com> Date: Sun, 14 Apr 2024 18:17:58 +0530 Subject: [PATCH 26/33] Update server.py --- server.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server.py b/server.py index 52c7f28..2945e29 100644 --- a/server.py +++ b/server.py @@ -1,6 +1,8 @@ from aiohttp import web import asyncio, logging, aiohttp, traceback -from configs import URL +#from configs import URL + +URL = "" r = web.RouteTableDef() From 903bf30455be757a5d0f0daa31dc6f196bc6c68c Mon Sep 17 00:00:00 2001 From: Ujjwalm2004 <130154620+Ujjwalm2004@users.noreply.github.com> Date: Sun, 14 Apr 2024 21:44:00 +0530 Subject: [PATCH 27/33] Update bot.py --- bot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot.py b/bot.py index e0f98c9..6a965ed 100644 --- a/bot.py +++ b/bot.py @@ -475,8 +475,8 @@ async def main(): ba = "0.0.0.0" port = int(os.getenv("PORT", 8080)) await web.TCPSite(wapp, ba, port).start() - await Bot.run() asyncio.create_task(ping_server()) + await Bot.run() if __name__ == '__main__': From b2aaa869e3dc0be6fd01c5981d7474c58eb76fc7 Mon Sep 17 00:00:00 2001 From: Ujjwalm2004 <130154620+Ujjwalm2004@users.noreply.github.com> Date: Sun, 14 Apr 2024 22:04:36 +0530 Subject: [PATCH 28/33] Update bot.py --- bot.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bot.py b/bot.py index 6a965ed..d231cf8 100644 --- a/bot.py +++ b/bot.py @@ -9,7 +9,8 @@ from pyrogram import ( Client, enums, - filters + filters, + idle ) from pyrogram.errors import ( UserNotParticipant, @@ -475,8 +476,8 @@ async def main(): ba = "0.0.0.0" port = int(os.getenv("PORT", 8080)) await web.TCPSite(wapp, ba, port).start() + await Bot.start() asyncio.create_task(ping_server()) - await Bot.run() if __name__ == '__main__': From d30194d9e5587a0541e91893877d39f37eb0f2f4 Mon Sep 17 00:00:00 2001 From: Ujjwalm2004 <130154620+Ujjwalm2004@users.noreply.github.com> Date: Sun, 14 Apr 2024 22:05:03 +0530 Subject: [PATCH 29/33] Update bot.py --- bot.py | 1 + 1 file changed, 1 insertion(+) diff --git a/bot.py b/bot.py index d231cf8..a88e6ed 100644 --- a/bot.py +++ b/bot.py @@ -478,6 +478,7 @@ async def main(): await web.TCPSite(wapp, ba, port).start() await Bot.start() asyncio.create_task(ping_server()) + idle() if __name__ == '__main__': From 51beb6c8ee76cb5f0d6a9a3e0bb79a8bf9ae489b Mon Sep 17 00:00:00 2001 From: Ujjwalm2004 <130154620+Ujjwalm2004@users.noreply.github.com> Date: Sun, 14 Apr 2024 22:19:03 +0530 Subject: [PATCH 30/33] Update and rename bot.py to plugins/commands.py --- bot.py => plugins/commands.py | 28 ++-------------------------- 1 file changed, 2 insertions(+), 26 deletions(-) rename bot.py => plugins/commands.py (97%) diff --git a/bot.py b/plugins/commands.py similarity index 97% rename from bot.py rename to plugins/commands.py index a88e6ed..154245d 100644 --- a/bot.py +++ b/plugins/commands.py @@ -9,8 +9,7 @@ from pyrogram import ( Client, enums, - filters, - idle + filters ) from pyrogram.errors import ( UserNotParticipant, @@ -24,6 +23,7 @@ Message ) from configs import Config +from bot import Bot from handlers.database import db from handlers.add_user_to_db import add_user_to_database from handlers.send_file import send_media_and_reply @@ -38,19 +38,9 @@ save_media_in_channel, save_batch_media_in_channel ) -from server import web_server, ping_server -from aiohttp import web MediaList = {} -Bot = Client( - name=Config.BOT_USERNAME, - in_memory=True, - bot_token=Config.BOT_TOKEN, - api_id=Config.API_ID, - api_hash=Config.API_HASH -) - @Bot.on_message(filters.private) async def _(bot: Client, cmd: Message): @@ -469,17 +459,3 @@ async def button(bot: Client, cmd: CallbackQuery): try: await cmd.answer() except QueryIdInvalid: pass - -async def main(): - wapp = web.AppRunner(await web_server()) - await wapp.setup() - ba = "0.0.0.0" - port = int(os.getenv("PORT", 8080)) - await web.TCPSite(wapp, ba, port).start() - await Bot.start() - asyncio.create_task(ping_server()) - idle() - - -if __name__ == '__main__': - asyncio.run(main()) From e51d16efb698096abbe51ad7ebd0d70fe73f6c3d Mon Sep 17 00:00:00 2001 From: Ujjwalm2004 <130154620+Ujjwalm2004@users.noreply.github.com> Date: Sun, 14 Apr 2024 22:21:59 +0530 Subject: [PATCH 31/33] Create bot.py --- bot.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 bot.py diff --git a/bot.py b/bot.py new file mode 100644 index 0000000..8ecf0ce --- /dev/null +++ b/bot.py @@ -0,0 +1,38 @@ +import os, logging, asyncio +from aiohttp import web +from pyrogram import Client +from configs import * +from server import web_server + +logging.basicConfig(level=logging.INFO, format='%(message)s') +logger = logging.getLogger("Filestore") + +Bot = Client + +class Filestore(Client): + + def __init__(self): + super().__init__( + "Filestore", + in_memory=True, + workers=500, + api_id=API_ID, + api_hash=API_HASH, + bot_token=BOT_TOKEN, + plugins=dict(root="plugins") + ) + + async def start(self): + await super().start() + logger.info("Bot Started successfully..๐Ÿ˜Ž๐Ÿค") + app = web.AppRunner(await web_server()) + await app.setup() + ba = "0.0.0.0" + await web.TCPSite(app, ba, 8080).start() + + async def stop(self, *args): + await super().stop() + logger.info("Bot Stopped") + +if __name__ == '__main__': + Filestore().run() From ef421dee4d396ac78340860857dcf1734ee11ad0 Mon Sep 17 00:00:00 2001 From: Ujjwalm2004 <130154620+Ujjwalm2004@users.noreply.github.com> Date: Sun, 14 Apr 2024 22:22:36 +0530 Subject: [PATCH 32/33] Update bot.py --- bot.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/bot.py b/bot.py index 8ecf0ce..8b702ac 100644 --- a/bot.py +++ b/bot.py @@ -7,8 +7,6 @@ logging.basicConfig(level=logging.INFO, format='%(message)s') logger = logging.getLogger("Filestore") -Bot = Client - class Filestore(Client): def __init__(self): From 36d7186afead86a8860eb613011c98f18dc53cfc Mon Sep 17 00:00:00 2001 From: Ujjwalm2004 <130154620+Ujjwalm2004@users.noreply.github.com> Date: Sun, 14 Apr 2024 22:24:10 +0530 Subject: [PATCH 33/33] Update commands.py --- plugins/commands.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/plugins/commands.py b/plugins/commands.py index 154245d..9135225 100644 --- a/plugins/commands.py +++ b/plugins/commands.py @@ -23,7 +23,6 @@ Message ) from configs import Config -from bot import Bot from handlers.database import db from handlers.add_user_to_db import add_user_to_database from handlers.send_file import send_media_and_reply @@ -42,12 +41,12 @@ MediaList = {} -@Bot.on_message(filters.private) +@Client.on_message(filters.private) async def _(bot: Client, cmd: Message): await handle_user_status(bot, cmd) -@Bot.on_message(filters.command("start") & filters.private) +@Client.on_message(filters.command("start") & filters.private) async def start(bot: Client, cmd: Message): if cmd.from_user.id in Config.BANNED_USERS: @@ -104,7 +103,7 @@ async def start(bot: Client, cmd: Message): await cmd.reply_text(f"Something went wrong!\n\n**Error:** `{err}`") -@Bot.on_message((filters.document | filters.video | filters.audio) & ~filters.chat(Config.DB_CHANNEL)) +@Client.on_message((filters.document | filters.video | filters.audio) & ~filters.chat(Config.DB_CHANNEL)) async def main(bot: Client, message: Message): if message.chat.type == enums.ChatType.PRIVATE: @@ -172,12 +171,12 @@ async def main(bot: Client, message: Message): ) -@Bot.on_message(filters.private & filters.command("broadcast") & filters.user(Config.BOT_OWNER) & filters.reply) +@Client.on_message(filters.private & filters.command("broadcast") & filters.user(Config.BOT_OWNER) & filters.reply) async def broadcast_handler_open(_, m: Message): await main_broadcast_handler(m, db) -@Bot.on_message(filters.private & filters.command("status") & filters.user(Config.BOT_OWNER)) +@Client.on_message(filters.private & filters.command("status") & filters.user(Config.BOT_OWNER)) async def sts(_, m: Message): total_users = await db.total_users_count() await m.reply_text( @@ -186,7 +185,7 @@ async def sts(_, m: Message): ) -@Bot.on_message(filters.private & filters.command("ban_user") & filters.user(Config.BOT_OWNER)) +@Client.on_message(filters.private & filters.command("ban_user") & filters.user(Config.BOT_OWNER)) async def ban(c: Client, m: Message): if len(m.command) == 1: @@ -230,7 +229,7 @@ async def ban(c: Client, m: Message): ) -@Bot.on_message(filters.private & filters.command("unban_user") & filters.user(Config.BOT_OWNER)) +@Client.on_message(filters.private & filters.command("unban_user") & filters.user(Config.BOT_OWNER)) async def unban(c: Client, m: Message): if len(m.command) == 1: @@ -269,7 +268,7 @@ async def unban(c: Client, m: Message): ) -@Bot.on_message(filters.private & filters.command("banned_users") & filters.user(Config.BOT_OWNER)) +@Client.on_message(filters.private & filters.command("banned_users") & filters.user(Config.BOT_OWNER)) async def _banned_users(_, m: Message): all_banned_users = await db.get_all_banned_users() @@ -294,13 +293,13 @@ async def _banned_users(_, m: Message): await m.reply_text(reply_text, True) -@Bot.on_message(filters.private & filters.command("clear_batch")) +@Client.on_message(filters.private & filters.command("clear_batch")) async def clear_user_batch(bot: Client, m: Message): MediaList[f"{str(m.from_user.id)}"] = [] await m.reply_text("Cleared your batch files successfully!") -@Bot.on_callback_query() +@Client.on_callback_query() async def button(bot: Client, cmd: CallbackQuery): cb_data = cmd.data