diff --git a/Bot.session b/Bot.session index aac799a..7f33fe3 100644 Binary files a/Bot.session and b/Bot.session differ diff --git a/filesharingbot.txt b/filesharingbot.txt index 7574aca..f9b60f6 100644 --- a/filesharingbot.txt +++ b/filesharingbot.txt @@ -13,3 +13,59 @@ https://t.me/codeflix_bots [08-Jul-24 14:16:35 - INFO] - root - Stop signal received (SIGINT). Exiting... [08-Jul-24 14:16:35 - INFO] - bot - Bot stopped. +[16-Jul-24 10:35:45 - INFO] - bot - Bot Running..! + +Created by +https://t.me/codeflix_bots +[16-Jul-24 10:35:45 - INFO] - bot - + + + ___ ___ ___ ___ ___ _ _____ _____ ___ _____ ___ + / __/ _ \| \| __| __| | |_ _\ \/ / _ )/ _ \_ _/ __| +| (_| (_) | |) | _|| _|| |__ | | > <| _ \ (_) || | \__ \___\___/|___/|___|_| |____|___/_/\_\___/\___/ |_| |___/ + + + +[16-Jul-24 10:37:55 - WARNING] - pyrogram.session.session - [Bot] Waiting for 5 seconds before continuing (required by "messages.EditMessage") +[16-Jul-24 10:37:55 - WARNING] - pyrogram.session.session - [Bot] Waiting for 5 seconds before continuing (required by "messages.EditMessage") +[16-Jul-24 10:37:55 - WARNING] - pyrogram.session.session - [Bot] Waiting for 5 seconds before continuing (required by "messages.EditMessage") +[16-Jul-24 10:37:55 - WARNING] - pyrogram.session.session - [Bot] Waiting for 4 seconds before continuing (required by "messages.SendMedia") +[16-Jul-24 10:37:59 - WARNING] - pyrogram.session.session - [Bot] Waiting for 3 seconds before continuing (required by "messages.SendMedia") +[16-Jul-24 10:38:01 - WARNING] - pyrogram.session.session - [Bot] Waiting for 5 seconds before continuing (required by "messages.EditMessage") +[16-Jul-24 10:38:01 - WARNING] - pyrogram.session.session - [Bot] Waiting for 5 seconds before continuing (required by "messages.EditMessage") +[16-Jul-24 10:38:02 - WARNING] - pyrogram.session.session - [Bot] Waiting for 3 seconds before continuing (required by "messages.SendMedia") +[16-Jul-24 10:39:26 - ERROR] - pyrogram.dispatcher - object async_generator can't be used in 'await' expression +Traceback (most recent call last): + File "C:\Users\Shubham_Basava\anaconda3\lib\site-packages\pyrogram\dispatcher.py", line 440, in handler_worker + await handler.callback(self.client, *args) + File "C:\Users\Shubham_Basava\anaconda3\lib\site-packages\pyrogram\handlers\message_handler.py", line 154, in resolve_future_or_callback + await self.original_callback(client, message, *args) + File "C:\Users\Shubham_Basava\Telegram\TestBot\plugins\link_generator.py", line 41, in batch + last_msg_id = await client.get_chat_history(db_channel_id, limit=1) +TypeError: object async_generator can't be used in 'await' expression +[16-Jul-24 10:40:15 - INFO] - root - Stop signal received (SIGINT). Exiting... +[16-Jul-24 10:40:15 - INFO] - bot - Bot stopped. +[16-Jul-24 10:41:14 - INFO] - bot - Bot Running..! + +Created by +https://t.me/codeflix_bots +[16-Jul-24 10:41:14 - INFO] - bot - + + + ___ ___ ___ ___ ___ _ _____ _____ ___ _____ ___ + / __/ _ \| \| __| __| | |_ _\ \/ / _ )/ _ \_ _/ __| +| (_| (_) | |) | _|| _|| |__ | | > <| _ \ (_) || | \__ \___\___/|___/|___|_| |____|___/_/\_\___/\___/ |_| |___/ + + + +[16-Jul-24 10:41:35 - WARNING] - pyrogram.session.session - [Bot] Waiting for 5 seconds before continuing (required by "messages.EditMessage") +[16-Jul-24 10:41:35 - WARNING] - pyrogram.session.session - [Bot] Waiting for 5 seconds before continuing (required by "messages.SendMedia") +[16-Jul-24 10:41:35 - WARNING] - pyrogram.session.session - [Bot] Waiting for 5 seconds before continuing (required by "messages.SendMedia") +[16-Jul-24 10:41:41 - WARNING] - pyrogram.session.session - [Bot] Waiting for 4 seconds before continuing (required by "messages.EditMessage") +[16-Jul-24 10:41:41 - WARNING] - pyrogram.session.session - [Bot] Waiting for 4 seconds before continuing (required by "messages.EditMessage") +[16-Jul-24 10:41:41 - WARNING] - pyrogram.session.session - [Bot] Waiting for 4 seconds before continuing (required by "messages.SendMedia") +[16-Jul-24 10:41:45 - WARNING] - pyrogram.session.session - [Bot] Waiting for 3 seconds before continuing (required by "messages.EditMessage") +[16-Jul-24 10:41:45 - WARNING] - pyrogram.session.session - [Bot] Waiting for 3 seconds before continuing (required by "messages.EditMessage") +[16-Jul-24 10:41:45 - WARNING] - pyrogram.session.session - [Bot] Waiting for 3 seconds before continuing (required by "messages.SendMedia") +[16-Jul-24 10:45:13 - INFO] - root - Stop signal received (SIGINT). Exiting... +[16-Jul-24 10:45:13 - INFO] - bot - Bot stopped. diff --git a/plugins/channel_post.py b/plugins/channel_post.py index 3e3df09..4dd5f13 100644 --- a/plugins/channel_post.py +++ b/plugins/channel_post.py @@ -9,7 +9,7 @@ from config import ADMINS, CHANNEL_ID, DISABLE_CHANNEL_BUTTON from helper_func import encode -@Bot.on_message(filters.private & filters.user(ADMINS) & ~filters.command(['start','users','broadcast','batch','genlink','stats'])) +@Bot.on_message(filters.private & filters.user(ADMINS) & ~filters.command(['start','users','broadcast','batch','genlink','stats','custom_batch'])) async def channel_post(client: Client, message: Message): reply_text = await message.reply_text("Please Wait...!", quote = True) try: diff --git a/plugins/start.py b/plugins/start.py index da326fc..8e1b280 100644 --- a/plugins/start.py +++ b/plugins/start.py @@ -1,7 +1,4 @@ -#(©)Codeflix_Bots - - - +# (©)Codeflix_Bots import os import asyncio @@ -15,8 +12,8 @@ from helper_func import subscribed, encode, decode, get_messages from database.database import add_user, del_user, full_userbase, present_user - - +broadcast_in_progress = False +cancel_broadcast = False @Bot.on_message(filters.command('start') & filters.private & subscribed) async def start_command(client: Client, message: Message): @@ -27,7 +24,7 @@ async def start_command(client: Client, message: Message): except: pass text = message.text - if len(text)>7: + if len(text) > 7: try: base64_string = text.split(" ", 1)[1] except: @@ -41,7 +38,7 @@ async def start_command(client: Client, message: Message): except: return if start <= end: - ids = range(start,end+1) + ids = range(start, end + 1) else: ids = [] i = start @@ -64,9 +61,13 @@ async def start_command(client: Client, message: Message): await temp_msg.delete() for msg in messages: + if cancel_broadcast: + await message.reply("Broadcast has been canceled.") + return if bool(CUSTOM_CAPTION) & bool(msg.document): - caption = CUSTOM_CAPTION.format(previouscaption = "" if not msg.caption else msg.caption.html, filename = msg.document.file_name) + caption = CUSTOM_CAPTION.format(previouscaption="" if not msg.caption else msg.caption.html, + filename=msg.document.file_name) else: caption = "" if not msg.caption else msg.caption.html @@ -76,11 +77,13 @@ async def start_command(client: Client, message: Message): reply_markup = None try: - await msg.copy(chat_id=message.from_user.id, caption = caption, parse_mode = ParseMode.HTML, reply_markup = reply_markup, protect_content=PROTECT_CONTENT) + await msg.copy(chat_id=message.from_user.id, caption=caption, parse_mode=ParseMode.HTML, + reply_markup=reply_markup, protect_content=PROTECT_CONTENT) await asyncio.sleep(0.5) except FloodWait as e: await asyncio.sleep(e.x) - await msg.copy(chat_id=message.from_user.id, caption = caption, parse_mode = ParseMode.HTML, reply_markup = reply_markup, protect_content=PROTECT_CONTENT) + await msg.copy(chat_id=message.from_user.id, caption=caption, parse_mode=ParseMode.HTML, + reply_markup=reply_markup, protect_content=PROTECT_CONTENT) except: pass return @@ -88,36 +91,34 @@ async def start_command(client: Client, message: Message): reply_markup = InlineKeyboardMarkup( [ [ - InlineKeyboardButton("⚡️ ᴀʙᴏᴜᴛ", callback_data = "about"), + InlineKeyboardButton("⚡️ ᴀʙᴏᴜᴛ", callback_data="about"), InlineKeyboardButton('🍁 sᴇʀɪᴇsғʟɪx', url='https://t.me/Team_Netflix/40') ] ] ) await message.reply_text( - text = START_MSG.format( - first = message.from_user.first_name, - last = message.from_user.last_name, - username = None if not message.from_user.username else '@' + message.from_user.username, - mention = message.from_user.mention, - id = message.from_user.id + text=START_MSG.format( + first=message.from_user.first_name, + last=message.from_user.last_name, + username=None if not message.from_user.username else '@' + message.from_user.username, + mention=message.from_user.mention, + id=message.from_user.id ), - reply_markup = reply_markup, - disable_web_page_preview = True, - quote = True + reply_markup=reply_markup, + disable_web_page_preview=True, + quote=True ) return - -#=====================================================================================## +# =====================================================================================## -WAIT_MSG = """"Processing ...""" +WAIT_MSG = """Processing ...""" -REPLY_ERROR = """Use this command as a replay to any telegram message with out any spaces.""" +REPLY_ERROR = """Use this command as a replay to any telegram message without any spaces.""" + +# =====================================================================================## -#=====================================================================================## - - @Bot.on_message(filters.command('start') & filters.private) async def not_joined(client: Client, message: Message): buttons = [ @@ -134,8 +135,8 @@ async def not_joined(client: Client, message: Message): buttons.append( [ InlineKeyboardButton( - text = '• ɴᴏᴡ ᴄʟɪᴄᴋ ʜᴇʀᴇ •', - url = f"https://t.me/{client.username}?start={message.command[1]}" + text='• ɴᴏᴡ ᴄʟɪᴄᴋ ʜᴇʀᴇ •', + url=f"https://t.me/{client.username}?start={message.command[1]}" ) ] ) @@ -143,27 +144,38 @@ async def not_joined(client: Client, message: Message): pass await message.reply( - text = FORCE_MSG.format( - first = message.from_user.first_name, - last = message.from_user.last_name, - username = None if not message.from_user.username else '@' + message.from_user.username, - mention = message.from_user.mention, - id = message.from_user.id - ), - reply_markup = InlineKeyboardMarkup(buttons), - quote = True, - disable_web_page_preview = True + text=FORCE_MSG.format( + first=message.from_user.first_name, + last=message.from_user.last_name, + username=None if not message.from_user.username else '@' + message.from_user.username, + mention=message.from_user.mention, + id=message.from_user.id + ), + reply_markup=InlineKeyboardMarkup(buttons), + quote=True, + disable_web_page_preview=True ) + @Bot.on_message(filters.command('users') & filters.private & filters.user(ADMINS)) async def get_users(client: Bot, message: Message): msg = await client.send_message(chat_id=message.chat.id, text=WAIT_MSG) users = await full_userbase() await msg.edit(f"{len(users)} users are using this bot") + @Bot.on_message(filters.private & filters.command('broadcast') & filters.user(ADMINS)) async def send_text(client: Bot, message: Message): + global broadcast_in_progress, cancel_broadcast + if message.reply_to_message: + if broadcast_in_progress: + await message.reply("A broadcast is already in progress. Please wait until it is finished.") + return + + broadcast_in_progress = True + cancel_broadcast = False + query = await full_userbase() broadcast_msg = message.reply_to_message total = 0 @@ -171,9 +183,20 @@ async def send_text(client: Bot, message: Message): blocked = 0 deleted = 0 unsuccessful = 0 - - pls_wait = await message.reply("Broadcasting Message.. This will Take Some Time") + + pls_wait = await message.reply( + "Broadcasting Message.. This will Take Some Time", + reply_markup=InlineKeyboardMarkup( + [[InlineKeyboardButton("Cancel Broadcast", callback_data="cancel_broadcast")]] + ) + ) + for chat_id in query: + if cancel_broadcast: + await pls_wait.edit("Broadcast has been canceled.") + broadcast_in_progress = False + return + try: await broadcast_msg.copy(chat_id) successful += 1 @@ -191,7 +214,7 @@ async def send_text(client: Bot, message: Message): unsuccessful += 1 pass total += 1 - + status = f"""Broadcast Completed Total Users: {total} @@ -199,10 +222,19 @@ async def send_text(client: Bot, message: Message): Blocked Users: {blocked} Deleted Accounts: {deleted} Unsuccessful: {unsuccessful}""" - - return await pls_wait.edit(status) + + await pls_wait.edit(status) + broadcast_in_progress = False else: msg = await message.reply(REPLY_ERROR) await asyncio.sleep(8) await msg.delete() + + +@Bot.on_callback_query(filters.regex("cancel_broadcast") & filters.user(ADMINS)) +async def cancel_broadcast_callback(client: Bot, callback_query: CallbackQuery): + global cancel_broadcast + cancel_broadcast = True + await callback_query.answer("Broadcast canceling...") +