async def ytdl(_, message): userLastDownloadTime = user_time.get(message.chat.id) try: if userLastDownloadTime > datetime.now(): wait_time = round((userLastDownloadTime - datetime.now()).total_seconds() / 60, 2) await message.reply_text(f"`انتظر {wait_time} كرمال الضغط عليي شوي 🥺`") return except: pass url = message.text.strip() await message.reply_chat_action("typing") try: title, thumbnail_url, formats = extractYt(url) now = datetime.now() user_time[message.chat.id] = now + \ timedelta(minutes=youtube_next_fetch) except Exception: await message.reply_text("`افففف منككك ... 😔 \nماقلتلك انا ماتبعتلي يا ارنب روابط لقوائم تشغيل فقط فيدوهات مفردة 😭 \n#error`") return buttons = InlineKeyboardMarkup(list(create_buttons(formats))) sentm = await message.reply_text("فففف هلكتني وانت تحمل 🥺🥺 خود الفيديو تبعك وريحني😒") try: # Todo add webp image support in thumbnail by default not supported by pyrogram # https://www.youtube.com await message.reply_photo(thumbnail_url, caption=title, reply_markup=buttons) await sentm.delete() except Exception as e: try: thumbnail_url = "https://telegra.ph/file/922824d2d952a38885bd4.jpg" await message.reply_photo(thumbnail_url, caption=title, reply_markup=buttons) except Exception as e: await sentm.edit( f"<code>{e}</code> #Error")
async def update_checker(): try: repo = Repo() except exc.NoSuchPathError as error: log.warning(f"Check update failed!\nDirectory {error} is not found!") return except exc.InvalidGitRepositoryError as error: log.warning(f"Check update failed!\nDirectory {error} does not seems to be a git repository") return except exc.GitCommandError as error: log.warning(f"Check update failed!\n{error}") return brname = repo.active_branch.name if brname not in OFFICIAL_BRANCH: return try: repo.create_remote('upstream', REPOSITORY) except BaseException: pass upstream = repo.remote('upstream') upstream.fetch(brname) changelog = await gen_chlog(repo, f'HEAD..upstream/{brname}') if not changelog: log.info(f'Nana is up-to-date with branch {brname}') return log.warning(f'New UPDATE available for [{brname}]!') text = f"**New UPDATE available for [{brname}]!**\n\n" text += f"**CHANGELOG:**\n`{changelog}`" button = InlineKeyboardMarkup([[InlineKeyboardButton("🔄 Update Now!", callback_data="update_now")]]) await setbot.send_message(Owner, text, reply_markup=button, parse_mode="markdown")
async def ytdl(_, message): userLastDownloadTime = user_time.get(message.chat.id) try: if userLastDownloadTime > datetime.now(): wait_time = round((userLastDownloadTime - datetime.now()).total_seconds() / 60, 2) await message.reply_text(f"`Wait {wait_time} Minutes before next Request`") return except: pass url = message.text.strip() await message.reply_chat_action("typing") try: title, thumbnail_url, formats = extractYt(url) now = datetime.now() user_time[message.chat.id] = now + \ timedelta(minutes=youtube_next_fetch) except Exception: await message.reply_text("`A fail tlat mai.. 😔 \nA chhhan chu, he Video Data hi ka hmu thei lo tlat. \n#error`") return buttons = InlineKeyboardMarkup(list(create_buttons(formats))) sentm = await message.reply_text("WAIT PANNU DA 🤣") try: # Todo add webp image support in thumbnail by default not supported by pyrogram # https://www.youtube.com/watch?v=lTTajzrSkCw await message.reply_photo(thumbnail_url, caption=title, reply_markup=buttons) await sentm.delete() except Exception as e: try: thumbnail_url = "https://telegra.ph/file/d75ec77d3d1a4a7f64548.jpg" await message.reply_photo(thumbnail_url, caption=title, reply_markup=buttons) except Exception as e: await sentm.edit( f"<code>{e}</code> #Error")
async def back_cb(_, callback_query: CallbackQuery): u_id = callback_query.from_user.id if u_id == Config.OWNER_ID or u_id in Config.SUDO_USERS: buttons = [[ InlineKeyboardButton("Open Gapps", callback_data="open_gapps") ], [ InlineKeyboardButton("Flame Gapps", callback_data="flame_gapps") ], [ InlineKeyboardButton("Nik Gapps", callback_data="nik_gapps") ]] await ubot.edit_inline_text( callback_query.inline_message_id, "**LATEST Android 10 arm64 Gapps**", reply_markup=InlineKeyboardMarkup(buttons)) else: await callback_query.answer( "Sorry You Can't Access This!\n\n 𝘿𝙚𝙥𝙡𝙤𝙮 𝙔𝙤𝙪𝙧 𝙊𝙬𝙣 𝙐𝙎𝙀𝙍𝙂𝙀-𝙓", show_alert=True)
async def flame_cb(_, callback_query: CallbackQuery): u_id = callback_query.from_user.id if u_id == Config.OWNER_ID or u_id in Config.SUDO_USERS: link = "https://sourceforge.net/projects/flamegapps/files/arm64/android-10/" url = get(link) if url.status_code == 404: return page = BeautifulSoup(url.content, 'lxml') content = page.tbody.tr date = content['title'] date2 = date.replace("-", "") flame = "{link}{date}/FlameGApps-10.0-{varient}-arm64-{date2}.zip/download" basic = flame.format(link=link, date=date, varient="basic", date2=date2) full = flame.format(link=link, date=date, varient="full", date2=date2) flame_g = [[ InlineKeyboardButton(text="FULL", url=full), InlineKeyboardButton(text="BASIC", url=basic) ], [ InlineKeyboardButton(text="⏪ Back", callback_data="back_gapps") ]] await ubot.edit_inline_text( callback_query.inline_message_id, "[\u200c](https://telegra.ph/file/c3cdea0642e1723f3304c.jpg)**FLAME GAPPS**", reply_markup=InlineKeyboardMarkup(flame_g)) else: await callback_query.answer( "Sorry You Can't Access This!\n\n 𝘿𝙚𝙥𝙡𝙤𝙮 𝙔𝙤𝙪𝙧 𝙊𝙬𝙣 𝙐𝙎𝙀𝙍𝙂𝙀-𝙓", show_alert=True)
async def vars_heroku(_client, query): text = "**⚙️ Welcome to Heroku Vars Settings!**\n" \ "`Setting your heroku config vars here!`\n" list_button = [[ InlineKeyboardButton("⬅ back️", callback_data="back"), InlineKeyboardButton("➕ add️", callback_data="add_vars") ]] if HEROKU_API: heroku = heroku3.from_key(HEROKU_API) heroku_applications = heroku.apps() if len(heroku_applications) >= 1: app = heroku_applications[0] config = app.config() # if config["api_id"]: # list_button.insert(0, [InlineKeyboardButton("api_id✅", callback_data="api_id")]) # else: # list_button.insert(0, [InlineKeyboardButton("api_id🚫", callback_data="api_id")]) configdict = config.to_dict() for x, y in configdict.items(): list_button.insert(0, [ InlineKeyboardButton("{}✅".format(x), callback_data="tes") ]) button = InlineKeyboardMarkup(list_button) await query.message.edit_text(text, reply_markup=button)
def help_group() -> dict: """This formats a help text that gets replied to the /help command in the group. Returns: dict: A dictionary to map to the reply_text(**args) function. """ help_text = (f"{Emoji.INFORMATION} **Information**\n" + "Ich bin ein Bot, um den Admins auszuhelfen. " + "Ausführliche Informationen gibt über die Buttons unten.") help_keyboard = InlineKeyboardMarkup([[ InlineKeyboardButton( text=f"{Emoji.INFORMATION} Ausführlichere Infos", url="https://t.me/ShModBot?start=help", ), InlineKeyboardButton( text=f"{Emoji.BLUE_BOOK} Quelltext", url="https://github.com/ColinTheShark/shmodbot", ), ]]) return { "text": help_text, "reply_markup": help_keyboard, "parse_mode": "markdown" }
async def un_auth(_client, message): if message.chat.id is not AdminSettings: msg = f""" Hi {message.chat.first_name}, You must be looking forward on how I work. In that case I can give you helpful links to self host me on your own. Here are some links for you """ buttons = [ [ InlineKeyboardButton( "Documentation", url="https://aman-a.gitbook.io/nana-remix/") ], [ InlineKeyboardButton( "Repository", url="https://github.com/pokurt/Nana-Remix"), InlineKeyboardButton("Support", url="https://t.me/nanabotsupport"), ], ] await message.reply(msg, reply_markup=InlineKeyboardMarkup(buttons)) else: return
async def get_button_settings(): me = await is_userbot_run() if me: toggle = "Stop Bot" else: toggle = "Start Bot" list_button = [[ InlineKeyboardButton(toggle, callback_data="toggle_startbot"), InlineKeyboardButton("Restart Bot", callback_data="restart_bot") ], [InlineKeyboardButton("Set Sticker", callback_data="setsticker")]] if HEROKU_API: list_button.append([ InlineKeyboardButton("Heroku Config Vars", callback_data="heroku_vars") ]) list_button.append([ InlineKeyboardButton("Restart Heroku app", callback_data="restart_heroku") ]) list_button.append([ InlineKeyboardButton("Change Repo Source", callback_data="change_repo") ]) return InlineKeyboardMarkup(list_button)
def markup_chat_actions(chat, btn_texts): u_limit_text = btn_texts['ulimit'].format(ulimit=chat.user_limit_day, coin=chat.coin) c_limit_text = btn_texts['climit'].format(climit=chat.chat_limit_day, coin=chat.coin) dice_time_text = btn_texts['dt'].format( dt_from=chat.dice_time_from.strftime("%H:%M"), dt_to=chat.dice_time_to.strftime("%H:%M")) back_text = btn_texts['back'] markup = InlineKeyboardMarkup( [[ InlineKeyboardButton(u_limit_text, callback_data=f'set.ulimit.{chat.chat_id}') ], [ InlineKeyboardButton(c_limit_text, callback_data=f'set.climit.{chat.chat_id}') ], [ InlineKeyboardButton(dice_time_text, callback_data=f'set.dt.{chat.chat_id}') ], [InlineKeyboardButton(back_text, callback_data='set.back')]]) return markup
async def settings(_client, message): try: me = await app.get_me() except ConnectionError: me = None text = "**⚙️ Welcome to Nana Settings!**\n" if not me: text += "-> Userbot: `Stopped (v{})`\n".format(USERBOT_VERSION) else: text += "-> Userbot: `Running (v{})`\n".format(USERBOT_VERSION) text += "-> Assistant: `Running (v{})`\n".format(ASSISTANT_VERSION) text += "-> Database: `{}`\n".format(DB_AVAILABLE) text += "-> Python: `{}`\n".format(python_version()) text += "\nJust setup what you need here" list_button = [ [ InlineKeyboardButton("Stop Bot", callback_data="toggle_startbot"), InlineKeyboardButton("Restart Bot", callback_data="restart_bot"), ], [InlineKeyboardButton("Set Sticker", callback_data="setsticker")], ] if HEROKU_API: list_button.append([ InlineKeyboardButton("Heroku Config Vars", callback_data="heroku_vars") ]) list_button.append([ InlineKeyboardButton("Restart Heroku app", callback_data="restart_heroku") ]) list_button.append([ InlineKeyboardButton("Change Repo Source", callback_data="change_repo") ]) button = InlineKeyboardMarkup(list_button) await message.reply(text, reply_markup=button)
def pyrogram_data(bot, update): global active_chats if update.from_user.id not in active_chats: active_chats[update.from_user.id] = {'actions': []} active_chats[update.from_user.id]['actions'].append('apks') start_string = "{}".format("downl") bot.edit_message_text( text="**📱 Apk Downloader Premium**\n\n__Step 1 of 2__\n" "\nOK! Send me search query in next message.", chat_id=update.from_user.id, reply_markup=InlineKeyboardMarkup( [ [ # Opens a web URL InlineKeyboardButton("⬅️ Retrun to Previous menu" , callback_data=start_string.encode("UTF-8")), ], ] ), message_id=update.message.message_id )
def pyrogram_data(bot, update): global active_chats active_chats[update.from_user.id] = {'actions': []} start_string = "{}".format("start") apk_string = "{}".format("apks") bot.edit_message_text( text=Translation.DOWNLOAD_TOOLS_TEXT, chat_id=update.from_user.id, reply_markup=InlineKeyboardMarkup( [ [ # First row # Generates a callback query when pressed InlineKeyboardButton("🔎 " + " Search Android Apps " , callback_data=apk_string.encode("UTF-8")) ], [ InlineKeyboardButton("🚫 Cancel" , callback_data=start_string.encode("UTF-8")) ] ] ), message_id=update.message.message_id )
def stars(app, call, texts): data = json.load(open('src/friendcodes.json', 'r')) cid = str(call.message.chat.id) uid = str(call.from_user.id) mid = call.message.message_id owner_uid = re.findall('[0-9]+', call.data)[0] raid = user_dict[owner_uid] if uid != raid.idd: text = texts['not_creator'] app.answer_callback_query(call.id, text, True) return None raid.stars = '⭐️' * int(call.data[-1]) text = texts['new_raid'].format( raid.pokemon + ' ' + raid.stars, raid.owner, raid.fc, raid.players[0] if len(raid.players) > 0 else '-', raid.players[1] if len(raid.players) > 1 else '-', raid.players[2] if len(raid.players) > 2 else '-', ) markup = InlineKeyboardMarkup([[ InlineKeyboardButton(text='🙋♂️ Join', callback_data='join' + str(raid.idd)), InlineKeyboardButton(text='🚫 Close', callback_data='done' + str(raid.idd)) ]]) app.edit_message_text(chat_id=cid, message_id=mid, text=text, parse_mode='HTML', reply_markup=markup)
async def ytdl(_, message): userLastDownloadTime = user_time.get(message.chat.id) try: if userLastDownloadTime > datetime.now(): wait_time = round((userLastDownloadTime - datetime.now()).total_seconds() / 60, 2) await message.reply_text(f"`Wait {wait_time} Minutes before next Request`") return except: pass url = message.text.strip() await message.reply_chat_action("typing") try: title, thumbnail_url, formats = extractYt(url) now = datetime.now() user_time[message.chat.id] = now + \ timedelta(minutes=youtube_next_fetch) except Exception: await message.reply_text("`Failed To Fetch Youtube Data... 😔 \nPossible Youtube Blocked server ip \n#error`") return buttons = InlineKeyboardMarkup(list(create_buttons(formats))) sentm = await message.reply_text("Processing Youtube Url 🔎 🔎 🔎") try: # Todo add webp image support in thumbnail by default not supported by pyrogram # https://www.youtube.com/watch?v=lTTajzrSkCw await message.reply_photo(thumbnail_url, caption=title, reply_markup=buttons) await sentm.delete() except Exception as e: try: thumbnail_url = "https://telegra.ph/file/b1b9a98977dc9ce3ced95.jpg" await message.reply_photo(thumbnail_url, caption=title, reply_markup=buttons) except Exception as e: await sentm.edit( f"<code>{e}</code> #Error")
async def start(c, m): if not await c.db.is_user_exist(m.chat.id): await c.db.add_user(m.chat.id) await c.send_message( Config.LOG_CHANNEL, f"New User [{m.from_user.first_name}](tg://user?id={m.chat.id}) started." ) await m.reply_text( text=f"Hi there {m.from_user.first_name}.\n\nI'm Screenshot Generator Bot. I can provide screenshots from your video files with out downloading the entire file (almost instantly). For more details check /help.", quote=True, reply_markup=InlineKeyboardMarkup( [ [ InlineKeyboardButton('😎 Create Legend', url='https://t.me/NGY_BOT'), InlineKeyboardButton('📣 Project Channel', url='https://t.me/NGY_BOTS') ], [ InlineKeyboardButton('📝 Updates Channel', url='https://t.me/NGY_BOTS') ] ] ) )
async def reboot_bot(client, query): await restart_all() text = "**⚙️ Welcome to Nana Settings!**\n" text += "-> Userbot: `Running (v{})`\n".format(USERBOT_VERSION) text += "-> Assistant: `Running (v{})`\n".format(ASSISTANT_VERSION) text += "-> Database: `{}`\n".format(DB_AVAILABLE) text += "-> Python: `{}`\n".format(python_version()) text += "\n✅ Bot was restarted!" list_button = [[ InlineKeyboardButton("Stop Bot", callback_data="toggle_startbot"), InlineKeyboardButton("Restart Bot", callback_data="restart_bot") ]] if HEROKU_API: list_button.append([ InlineKeyboardButton("Restart Heroku app", callback_data="restart_heroku") ]) button = InlineKeyboardMarkup(list_button) try: await query.message.edit_text(text, reply_markup=button) except errors.exceptions.bad_request_400.MessageNotModified: pass await client.answer_callback_query(query.id, "Please wait for bot restarting...")
async def start(c, m): if not await db.is_user_exist(m.chat.id): await db.add_user(m.chat.id) await c.send_message( Config.LOG_CHANNEL, f"New User [{m.from_user.first_name}](tg://user?id={m.chat.id}) started." ) await m.reply_text( text= f"Hi {m.from_user.first_name}.\n\nI'm Screenshot Generator Bot. I'm **Not ~~The Only Screenshot Bot~~** that gives you screenshots with out downloading the entire file. Send me any telegram streamable/document video file or a streaming link, I'll generate the screenshots for you.", quote=True, reply_markup=InlineKeyboardMarkup([ [ InlineKeyboardButton( 'Source 😒', url='https://github.com/odysseusmax/animated-lamp') ], [ InlineKeyboardButton('Project Channel', url='https://t.me/odbots') ], ]))
def poketypes_back(client: app, callback_query: CallbackQuery): q_data = callback_query.data query_data = q_data.split('_')[1].lower() user_id = int(q_data.split('_')[2]) if callback_query.from_user.id == user_id: p_type = data[query_data][query_data]['type'] try: get_pt = f"{p_type['type1']}, {p_type['type2']:}" keyboard = ([[ InlineKeyboardButton( p_type['type1'], callback_data= f"poket_{p_type['type1']}_{query_data}_{user_id}"), InlineKeyboardButton( p_type['type2'], callback_data= f"poket_{p_type['type2']}_{query_data}_{user_id}") ]]) except KeyError: get_pt = f"{p_type['type1']}" keyboard = ([[ InlineKeyboardButton( p_type['type1'], callback_data= f"poket_{p_type['type1']}_{query_data}_{user_id}") ]]) callback_query.message.edit_text(( f"Pokemon: `{query_data}`\n\n" f"Types: `{get_pt}`\n\n" "__Click the button below to get the pokemon's type's/types' effectiveness and weakness!__" ), reply_markup=InlineKeyboardMarkup( keyboard)) else: callback_query.answer(text="You're not allowed to use this!", show_alert=True)
async def help(c, m): ## Doing Force Sub 🤣 update_channel = UPDATES_CHANNEL if update_channel: try: user = await c.get_chat_member(update_channel, m.chat.id) if user.status == "kicked": await c.send_message( chat_id=m.chat.id, text= "Sorry Sir, You are Banned to use me. Contact my [Support Group](https://t.me/safothebot).", parse_mode="markdown", disable_web_page_preview=True) return except UserNotParticipant: await c.send_message( chat_id=m.chat.id, text= "**Hey, \nPlease Join My Updates Channel To Use This Bot!**", reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton("Join Updates Channel", url=f"https://t.me/{update_channel}") ]]), parse_mode="markdown") return except Exception: await c.send_message( chat_id=m.chat.id, text= "Something went Wrong. Contact my [Support Group](https://t.me/safothebot).", parse_mode="markdown", disable_web_page_preview=True) return ## await m.reply_text(text=HELP_TEXT.format(m.from_user.first_name), quote=True)
def start(client, message): split = message.text.split() if len(split) == 2: if (split[1] in bot.pending and message.from_user.id == bot.pending[split[1]]["user_id"]): if is_valid(split[1]): message.reply( bot.settings["disclaimer"], reply_markup=InlineKeyboardMarkup([ [ InlineKeyboardButton( text="Accetto", callback_data=f"accept_{split[1]}") ], [ InlineKeyboardButton( text="Declino", callback_data=f"refuse_{split[1]}") ], ]), disable_web_page_preview=True, ) else: message.reply("Il link non è più valido.")
def updateCb(client, callback_query,redis): if callback_query.inline_message_id: return False date = callback_query.data userID = callback_query.from_user.id userFN = callback_query.from_user.first_name username = callback_query.from_user.username chatID = callback_query.message.chat.id message_id = callback_query.message.message_id go = """{}꒐ ({}),❌ {}꒐ ({}),⭕️""" go3 = """{}꒐ ({}) {}꒐ ({}) 🎊꒐ الفائز ({})""" go2 = """{}꒐ ({}) {}꒐ ({}) 🔴꒐ تعادل""" if re.search("rex=",date): tx = callback_query.message.text p1 = date.split("=")[1] if userID == int(p1): start = """👋🏻꒐ ❌⭕️ 👤꒐ اضغط للعب مع ({})""".format(userFN) kb = InlineKeyboardMarkup([[InlineKeyboardButton("العب", callback_data="xo="+str(userID))]]) Bot("sendMessage",{"chat_id":chatID,"text":start,"disable_web_page_preview":True,"reply_markup":kb}) Bot("editMessageText",{"chat_id":chatID,"message_id":message_id,"text":tx,"disable_web_page_preview":True}) else: Bot("answerCallbackQuery",{"callback_query_id":callback_query.id,"text":"عذراً اللعبه ليست لك","show_alert":True}) if re.search("^xo.pyplay$",date): start = """👋🏻꒐ ❌⭕️ 👤꒐ اضغط للعب مع ({})""".format(userFN) kb = InlineKeyboardMarkup([[InlineKeyboardButton("العب", callback_data="xo="+str(userID))]]) Bot("editMessageText",{"chat_id":chatID,"message_id":message_id,"text":start,"disable_web_page_preview":True,"reply_markup":kb}) if re.search("xo=",date): p1 = date.split("=")[1] if userID == int(p1): Bot("answerCallbackQuery",{"callback_query_id":callback_query.id,"text":"انت من بدأت اللعبه انتظر احد اصدقائك","show_alert":True}) return False try: getUser = client.get_users(p1) fn1 = getUser.first_name except Exception as e: fn1 = p1 p2 = userID fn2 = userFN tb = [0,0,0,0,0,0,0,0,0] cd = "xp{}={}={}={}".format(1,p1,p2,tb) i = 0 x = 0 ar = [] a = [] em = "◻️" while i < 3: while x < 3: cd = "xp{}={}={}={}={}.{}".format(1,p1,p2,tb,i,x) a.append(InlineKeyboardButton(em,callback_data=cd)) x += 1 i += 1 x = 0 ar.append(a) a = [] ar.append([InlineKeyboardButton("📣",url="t.me/wzsss")]) kb = InlineKeyboardMarkup(ar) Bot("editMessageText",{"chat_id":chatID,"message_id":message_id,"text":go.format("👉🏻",fn1,"🔄",fn2),"disable_web_page_preview":True,"reply_markup":kb}) if re.search("xp(1|2)=",date): play = date.split("=")[0].replace("xp","") p1 = date.split("=")[1] p2 = date.split("=")[2] ck = date.split("=")[3] rt = date.split("=")[4] r = rt.split(".")[0] t = rt.split(".")[1] if int(play) == 1: playing = p1 nextT = p2 nextTN = 2 xo = 1#"X" em = "❌" elif int(play) == 2: playing = p2 xo = 2#"O" nextT = p1 nextTN = 1 em = "⭕️" if userID != int(playing): Bot("answerCallbackQuery",{"callback_query_id":callback_query.id,"text":"انتظر دورك","show_alert":True}) return False x = 0 a =[] ar = [] for i in json.loads(ck): a.append(i) x += 1 if x == 3: x = 0 ar.append(a) a = [] tx = callback_query.message.reply_markup.inline_keyboard if ar[int(r)][int(t)] == 0: ar[int(r)][int(t)] = xo else: Bot("answerCallbackQuery",{"callback_query_id":callback_query.id,"text":"لايمكنك اللعب هنا","show_alert":True}) return False tb = ar[0] + ar[1] + ar[2] win,xRo = getwin(tb) if win: if xRo == 1: fn1,fn2 = get(client,userID,userFN,p1,p2) redis.hincrby("{}Nbot:{}:points".format(BOT_ID,chatID),p1,10) kb = InlineKeyboardMarkup([[InlineKeyboardButton("اللعب مجدداً",callback_data="rex={}".format(p1))]]) Bot("editMessageText",{"chat_id":chatID,"message_id":message_id,"text":go3.format("❌",fn1,"⭕️",fn2,fn1)+"\n"+kbtotx(tb),"disable_web_page_preview":True,"reply_markup":kb}) return False if xRo == 2: fn1,fn2 = get(client,userID,userFN,p1,p2) redis.hincrby("{}Nbot:{}:points".format(BOT_ID,chatID),p2,10) kb = InlineKeyboardMarkup([[InlineKeyboardButton("اللعب مجدداً",callback_data="rex={}".format(p1))]]) Bot("editMessageText",{"chat_id":chatID,"message_id":message_id,"text":go3.format("❌",fn1,"⭕️",fn2,fn2)+"\n"+kbtotx(tb),"disable_web_page_preview":True,"reply_markup":kb}) return False if xRo == "tie": fn1,fn2 = get(client,userID,userFN,p1,p2) redis.hincrby("{}Nbot:{}:points".format(BOT_ID,chatID),p1,3) redis.hincrby("{}Nbot:{}:points".format(BOT_ID,chatID),p2,3) kb = InlineKeyboardMarkup([[InlineKeyboardButton("اللعب مجدداً",callback_data="rex={}".format(p1))]]) Bot("editMessageText",{"chat_id":chatID,"message_id":message_id,"text":go2.format("❌",fn1,"⭕️",fn2)+"\n"+kbtotx(tb),"disable_web_page_preview":True,"reply_markup":kb}) return False win = getwin(tb) i = 0 x = 0 ar = [] a = [] while i < 3: while x < 3: cd = "xp{}={}={}={}={}.{}".format(nextTN,p1,p2,tb,i,x) if int(r) == i and int(t) == x: a.append(InlineKeyboardButton(em,callback_data=cd)) else: a.append(InlineKeyboardButton(tx[i][x].text,callback_data=cd)) x += 1 i += 1 x = 0 ar.append(a) a = [] ar.append([InlineKeyboardButton("📣",url="t.me/wzsss")]) kb = InlineKeyboardMarkup(ar) if nextTN == 1: e1 = "👉🏻" else: e1 = "🔄" if nextTN == 2: e2 = "👉🏻" else: e2 = "🔄" fn1,fn2 = get(client,userID,userFN,p1,p2) v= Bot("editMessageText",{"chat_id":chatID,"message_id":message_id,"text":go.format(e1,fn1,e2,fn2),"disable_web_page_preview":True,"reply_markup":kb})
async def echo(bot, update): if update.from_user.id not in AUTH_USERS: await update.delete() return # LOGGER.info(update) # await bot.send_chat_action( # chat_id=update.chat.id, # action="typing" # ) LOGGER.info(update.from_user) url = update.text youtube_dl_username = None youtube_dl_password = None file_name = None if "|" in url: url_parts = url.split("|") if len(url_parts) == 2: url = url_parts[0] file_name = url_parts[1] elif len(url_parts) == 4: url = url_parts[0] file_name = url_parts[1] youtube_dl_username = url_parts[2] youtube_dl_password = url_parts[3] else: for entity in update.entities: if entity.type == "text_link": url = entity.url elif entity.type == "url": o = entity.offset l = entity.length url = url[o:o + l] if url is not None: url = url.strip() if file_name is not None: file_name = file_name.strip() # https://stackoverflow.com/a/761825/4723940 if youtube_dl_username is not None: youtube_dl_username = youtube_dl_username.strip() if youtube_dl_password is not None: youtube_dl_password = youtube_dl_password.strip() LOGGER.info(url) LOGGER.info(file_name) else: for entity in update.entities: if entity.type == "text_link": url = entity.url elif entity.type == "url": o = entity.offset l = entity.length url = url[o:o + l] if HTTP_PROXY is not None: command_to_exec = [ "youtube-dl", "--no-warnings", "--youtube-skip-dash-manifest", "-j", url, "--proxy", HTTP_PROXY ] else: command_to_exec = [ "youtube-dl", "--no-warnings", "--youtube-skip-dash-manifest", "-j", url ] if youtube_dl_username is not None: command_to_exec.append("--username") command_to_exec.append(youtube_dl_username) if youtube_dl_password is not None: command_to_exec.append("--password") command_to_exec.append(youtube_dl_password) # logger.info(command_to_exec) process = await asyncio.create_subprocess_exec( *command_to_exec, # stdout must a pipe to be accessible as process.stdout stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE, ) # Wait for the subprocess to finish stdout, stderr = await process.communicate() e_response = stderr.decode().strip() # logger.info(e_response) t_response = stdout.decode().strip() # logger.info(t_response) # https://github.com/rg3/youtube-dl/issues/2630#issuecomment-38635239 if e_response and "nonnumeric port" not in e_response: # logger.warn("Status : FAIL", exc.returncode, exc.output) error_message = e_response.replace( "please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see https://yt-dl.org/update on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.", "") if "This video is only available for registered users." in error_message: error_message += Translation.SET_CUSTOM_USERNAME_PASSWORD await update.reply_text(text=Translation.NO_VOID_FORMAT_FOUND.format( str(error_message)), quote=True, parse_mode="html", disable_web_page_preview=True) return False if t_response: # logger.info(t_response) x_reponse = t_response if "\n" in x_reponse: x_reponse, _ = x_reponse.split("\n") response_json = json.loads(x_reponse) save_ytdl_json_path = DOWNLOAD_LOCATION + \ "/" + str(update.from_user.id) + ".json" with open(save_ytdl_json_path, "w", encoding="utf8") as outfile: json.dump(response_json, outfile, ensure_ascii=False) # logger.info(response_json) inline_keyboard = [] duration = None if "duration" in response_json: duration = response_json["duration"] if "formats" in response_json: for formats in response_json["formats"]: format_id = formats.get("format_id") format_string = formats.get("format_note") if format_string is None: format_string = formats.get("format") format_ext = formats.get("ext") approx_file_size = "" if "filesize" in formats: approx_file_size = humanbytes(formats["filesize"]) cb_string_video = "{}|{}|{}".format("video", format_id, format_ext) cb_string_file = "{}|{}|{}".format("file", format_id, format_ext) if format_string is not None and not "audio only" in format_string: ikeyboard = [ InlineKeyboardButton( "S " + format_string + " video " + approx_file_size + " ", callback_data=(cb_string_video).encode("UTF-8")), InlineKeyboardButton( "D " + format_ext + " " + approx_file_size + " ", callback_data=(cb_string_file).encode("UTF-8")) ] """if duration is not None: cb_string_video_message = "{}|{}|{}".format( "vm", format_id, format_ext) ikeyboard.append( pyrogram.InlineKeyboardButton( "VM", callback_data=( cb_string_video_message).encode("UTF-8") ) )""" else: # special weird case :\ ikeyboard = [ InlineKeyboardButton( "SVideo [" + "] ( " + approx_file_size + " )", callback_data=(cb_string_video).encode("UTF-8")), InlineKeyboardButton( "DFile [" + "] ( " + approx_file_size + " )", callback_data=(cb_string_file).encode("UTF-8")) ] inline_keyboard.append(ikeyboard) if duration is not None: cb_string_64 = "{}|{}|{}".format("audio", "64k", "mp3") cb_string_128 = "{}|{}|{}".format("audio", "128k", "mp3") cb_string = "{}|{}|{}".format("audio", "320k", "mp3") inline_keyboard.append([ InlineKeyboardButton( "MP3 " + "(" + "64 kbps" + ")", callback_data=cb_string_64.encode("UTF-8")), InlineKeyboardButton( "MP3 " + "(" + "128 kbps" + ")", callback_data=cb_string_128.encode("UTF-8")) ]) inline_keyboard.append([ InlineKeyboardButton( "MP3 " + "(" + "320 kbps" + ")", callback_data=cb_string.encode("UTF-8")) ]) else: format_id = response_json["format_id"] format_ext = response_json["ext"] cb_string_file = "{}|{}|{}".format("file", format_id, format_ext) cb_string_video = "{}|{}|{}".format("video", format_id, format_ext) inline_keyboard.append([ InlineKeyboardButton( "SVideo", callback_data=(cb_string_video).encode("UTF-8")), InlineKeyboardButton( "DFile", callback_data=(cb_string_file).encode("UTF-8")) ]) cb_string_file = "{}={}={}".format("file", format_id, format_ext) cb_string_video = "{}={}={}".format("video", format_id, format_ext) inline_keyboard.append([ InlineKeyboardButton( "video", callback_data=(cb_string_video).encode("UTF-8")), InlineKeyboardButton( "file", callback_data=(cb_string_file).encode("UTF-8")) ]) reply_markup = InlineKeyboardMarkup(inline_keyboard) # logger.info(reply_markup) thumbnail = DEF_THUMB_NAIL_VID_S thumbnail_image = DEF_THUMB_NAIL_VID_S if "thumbnail" in response_json: if response_json["thumbnail"] is not None: thumbnail = response_json["thumbnail"] thumbnail_image = response_json["thumbnail"] thumb_image_path = DownLoadFile( thumbnail_image, DOWNLOAD_LOCATION + "/" + str(update.from_user.id) + ".jpg", 128, None, # bot, Translation.DOWNLOAD_START, update.message_id, update.chat.id) await update.reply_photo( photo=thumb_image_path, quote=True, caption=Translation.FORMAT_SELECTION.format(thumbnail) + "\n" + Translation.SET_CUSTOM_USERNAME_PASSWORD, reply_markup=reply_markup, parse_mode="html") else: # fallback for nonnumeric port a.k.a seedbox.io inline_keyboard = [] cb_string_file = "{}={}={}".format("file", "LFO", "NONE") cb_string_video = "{}={}={}".format("video", "OFL", "ENON") inline_keyboard.append([ InlineKeyboardButton( "SVideo", callback_data=(cb_string_video).encode("UTF-8")), InlineKeyboardButton( "DFile", callback_data=(cb_string_file).encode("UTF-8")) ]) reply_markup = InlineKeyboardMarkup(inline_keyboard) await update.reply_photo( photo=DEF_THUMB_NAIL_VID_S, quote=True, caption=Translation.FORMAT_SELECTION.format(""), reply_markup=reply_markup, parse_mode="html", reply_to_message_id=update.message_id)
DEFAULT_RESULTS = [ InlineQueryResultArticle( title="About Pyrogram", input_message_content=InputTextMessageContent( f"{Emoji.FIRE} **Pyrogram**\n\n" f"Pyrogram is an elegant, easy-to-use Telegram client library and framework written from the ground up in " f"Python and C. It enables you to easily create custom apps using both user and bot identities (bot API " f"alternative) via the MTProto API.", disable_web_page_preview=True, ), reply_markup=InlineKeyboardMarkup( [[ InlineKeyboardButton(f"{Emoji.BUSTS_IN_SILHOUETTE} Community", url="https://t.me/pyrogram") ], [ InlineKeyboardButton(f"{Emoji.CARD_INDEX_DIVIDERS} GitHub", url="https://github.com/pyrogram"), InlineKeyboardButton(f"{Emoji.OPEN_BOOK} Docs", url="https://docs.pyrogram.org") ]]), description= "Pyrogram is an elegant, easy-to-use Telegram client library and framework.", thumb_url=FIRE_THUMB, ), InlineQueryResultArticle( title="About this Bot", input_message_content=InputTextMessageContent( HELP, disable_web_page_preview=True, parse_mode="markdown"), reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton(f"{Emoji.CARD_INDEX_DIVIDERS} Source Code",
async def catch_youtube_dldata(c, q): filename = None cb_data = q.data.strip() # Callback Data Check yturl = cb_data.split("||")[-1] format_id = cb_data.split("||")[-2] if not cb_data.startswith(("video", "audio", "docaudio", "docvideo")): print("no data found") raise ContinuePropagation filext = "%(title)s.%(ext)s" userdir = os.path.join(os.getcwd(), "downloads", str(q.message.chat.id)) if not os.path.isdir(userdir): os.makedirs(userdir) await q.edit_message_reply_markup( InlineKeyboardMarkup([[InlineKeyboardButton("Downloading...", callback_data="down")]])) filepath = os.path.join(userdir, filext) # await q.edit_message_reply_markup([[InlineKeyboardButton("Processing..")]]) audio_command = [ "youtube-dl", "-c", "--prefer-ffmpeg", "--extract-audio", "--audio-format", "mp3", "--audio-quality", format_id, "-o", filepath, yturl, ] video_command = [ "youtube-dl", "-c", "--embed-subs", "-f", f"{format_id}+bestaudio", "-o", filepath, "--hls-prefer-ffmpeg", yturl] loop = asyncio.get_event_loop() med = None if cb_data.startswith("audio"): filename = await downloadaudiocli(audio_command) med = InputMediaAudio( media=filename, caption=os.path.basename(filename), title=os.path.basename(filename) ) if cb_data.startswith("video"): filename = await downloadvideocli(video_command) dur = round(duration(filename)) med = InputMediaVideo( media=filename, duration=dur, caption=os.path.basename(filename), supports_streaming=True ) if cb_data.startswith("docaudio"): filename = await downloadaudiocli(audio_command) med = InputMediaDocument( media=filename, caption=os.path.basename(filename), ) if cb_data.startswith("docvideo"): filename = await downloadvideocli(video_command) dur = round(duration(filename)) med = InputMediaDocument( media=filename, caption=os.path.basename(filename), ) if med: loop.create_task(send_file(c, q, med, filename)) else: print("med not found")
async def challenge_user(client: Client, message: Message): target = message.new_chat_members[0] if message.from_user.id != target.id: if target.is_self: group_config = _config.get(str(message.chat.id), _config["*"]) try: await client.send_message( message.chat.id, group_config["msg_self_introduction"]) _me: User = await client.get_me() await client.send_message( int(_channel), _config["msg_into_group"].format( botid=str(_me.id), groupid=str(message.chat.id), grouptitle=str(message.chat.title), ), parse_mode="Markdown", ) except ChannelPrivate: return return try: await client.restrict_chat_member(chat_id=message.chat.id, user_id=target.id) except ChatAdminRequired: return group_config = _config.get(str(message.chat.id), _config["*"]) challenge = Challenge() def generate_challenge_button(e): choices = [[ InlineKeyboardButton(str(c), callback_data=bytes(str(c), encoding="utf-8")) ] for c in e.choices()] return choices + [[ InlineKeyboardButton(group_config["msg_approve_manually"], callback_data=b"+"), InlineKeyboardButton(group_config["msg_refuse_manually"], callback_data=b"-"), ]] timeout = group_config["challenge_timeout"] reply_message = await client.send_message( message.chat.id, group_config["msg_challenge"].format(timeout=timeout, challenge=challenge.qus()), reply_to_message_id=message.message_id, reply_markup=InlineKeyboardMarkup( generate_challenge_button(challenge)), ) timeout_event = _Timer( challenge_timeout(client, message.chat.id, message.from_user.id, reply_message.message_id), timeout=group_config["challenge_timeout"], ) _cch_lock.acquire() _current_challenges["{chat}|{msg}".format( chat=message.chat.id, msg=reply_message.message_id)] = (challenge, message.from_user.id, timeout_event) _cch_lock.release()
async def convert_to_video(bot, update): try: await bot.get_chat_member("@TG_BotZ", update.chat.id) except UserNotParticipant: await bot.send_message( chat_id=update.chat.id, text=Translation.JOIN, reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton('😎 Join Channel 😎', url='https://t.me/Tg_BotZ') ]]) ) return TRChatBase(update.from_user.id, update.text, "converttovideo") if update.reply_to_message is not None: description = Translation.CUSTOM_CAPTION_UL_FILE download_location = Config.DOWNLOAD_LOCATION + "/" a = await bot.send_message( chat_id=update.chat.id, text=Translation.DOWNLOAD_START, reply_to_message_id=update.message_id ) c_time = time.time() the_real_download_location = await bot.download_media( message=update.reply_to_message, file_name=download_location, progress=progress_for_pyrogram, progress_args=( Translation.DOWNLOAD_START, a, c_time ) ) if the_real_download_location is not None: bot.edit_message_text( text=Translation.SAVED_RECVD_DOC_FILE, chat_id=update.chat.id, message_id=a.message_id ) # don't care about the extension # await bot.edit_message_text( # text=Translation.UPLOAD_START, # chat_id=update.chat.id, # message_id=a.message_id # ) logger.info(the_real_download_location) # get the correct width, height, and duration for videos greater than 10MB # ref: message from @BotSupport width = 0 height = 0 duration = 0 metadata = extractMetadata(createParser(the_real_download_location)) if metadata.has("duration"): duration = metadata.get('duration').seconds thumb_image_path = Config.DOWNLOAD_LOCATION + "/" + str(update.from_user.id) + ".jpg" if not os.path.exists(thumb_image_path): thumb_image_path = await take_screen_shot( the_real_download_location, os.path.dirname(the_real_download_location), random.randint( 0, duration - 1 ) ) logger.info(thumb_image_path) # 'thumb_image_path' will be available now metadata = extractMetadata(createParser(thumb_image_path)) if metadata.has("width"): width = metadata.get("width") if metadata.has("height"): height = metadata.get("height") # get the correct width, height, and duration for videos greater than 10MB # resize image # ref: https://t.me/PyrogramChat/44663 # https://stackoverflow.com/a/21669827/4723940 Image.open(thumb_image_path).convert("RGB").save(thumb_image_path) img = Image.open(thumb_image_path) # https://stackoverflow.com/a/37631799/4723940 # img.thumbnail((90, 90)) img.resize((90, height)) img.save(thumb_image_path, "JPEG") # https://pillow.readthedocs.io/en/3.1.x/reference/Image.html#create-thumbnails # try to upload file c_time = time.time() await bot.send_video( chat_id=update.chat.id, video=the_real_download_location, caption=description, duration=duration, width=width, height=height, supports_streaming=True, # reply_markup=reply_markup, thumb=thumb_image_path, reply_to_message_id=update.reply_to_message.message_id, progress=progress_for_pyrogram, progress_args=( Translation.UPLOAD_START, a, c_time ) ) try: os.remove(the_real_download_location) # os.remove(thumb_image_path) except: pass await bot.edit_message_text( text=Translation.AFTER_SUCCESSFUL_UPLOAD_MSG, chat_id=update.chat.id, message_id=a.message_id, disable_web_page_preview=True ) else: await bot.send_message( chat_id=update.chat.id, text=Translation.REPLY_TO_DOC_FOR_C2V, reply_to_message_id=update.message_id )
async def check_progress_for_dl(aria2, gid, event, previous_message): try: file = aria2.get_download(gid) complete = file.is_complete is_file = file.seeder if not complete: if not file.error_message: msg = "" # sometimes, this weird https://t.me/c/1220993104/392975 # error creeps up # TODO: temporary workaround downloading_dir_name = "N/A" try: # another derp -_- # https://t.me/c/1220993104/423318 downloading_dir_name = str(file.name) except: pass # msg = f"\nDownloading File: `{downloading_dir_name}`" msg += f"\nSpeed: {file.download_speed_string()} 🔽 / {file.upload_speed_string()} 🔼" msg += f"\nProgress: {file.progress_string()}" msg += f"\nTotal Size: {file.total_length_string()}" if is_file is None : msg += f"\n<b>Connections:</b> {file.connections}" else : msg += f"\n<b>Info:</b>[ P : {file.connections} || S : {file.num_seeders} ]" # msg += f"\nStatus: {file.status}" msg += f"\nETA: {file.eta_string()}" msg += f"\nGID: <code>{gid}</code>" inline_keyboard = [] ikeyboard = [] ikeyboard.append(InlineKeyboardButton("Cancel 🚫", callback_data=(f"cancel {gid}").encode("UTF-8"))) inline_keyboard.append(ikeyboard) reply_markup = InlineKeyboardMarkup(inline_keyboard) #msg += reply_markup LOGGER.info(msg) if msg != previous_message: await event.edit(msg, reply_markup=reply_markup) previous_message = msg else: msg = file.error_message await asyncio.sleep(EDIT_SLEEP_TIME_OUT) await event.edit(f"`{msg}`") return False await asyncio.sleep(EDIT_SLEEP_TIME_OUT) await check_progress_for_dl(aria2, gid, event, previous_message) else: await asyncio.sleep(EDIT_SLEEP_TIME_OUT) await event.edit(f"File Downloaded Successfully: `{file.name}`") return True except Exception as e: LOGGER.info(str(e)) if " not found" in str(e) or "'file'" in str(e): await event.edit("Download Canceled") return False elif " depth exceeded" in str(e): file.remove(force=True) await event.edit("Download Auto Canceled\nYour Torrent/Link is Dead.") return False else: LOGGER.info(str(e)) await event.edit("<u>error</u> :\n`{}` \n\n#error".format(str(e))) return
def send_msg(type, client, message, textM, Lhash, T, redis): userID = message.from_user.id userFN = message.from_user.first_name chatID = message.chat.id text = message.text c = importlib.import_module("lang.arcmd") r = importlib.import_module("lang.arreply") if type == "LU": if re.search(c.stL, text): Tp = "LtoU" if re.search(c.stU, text): Tp = "UtoL" BY = "<a href=\"tg://user?id={}\">{}</a>".format(userID, userFN) tx = textM.format(BY, T) b = json.dumps(["LandU", Lhash, userID, Tp]) v = InlineKeyboardMarkup( [[InlineKeyboardButton(r.Corder, callback_data=b)]]) Bot( "sendMessage", { "chat_id": chatID, "text": tx, "reply_to_message_id": message.message_id, "parse_mode": "html", "disable_web_page_preview": True, "reply_markup": v }) if type == "LUN": BY = "<a href=\"tg://user?id={}\">{}</a>".format(userID, userFN) tx = textM.format(BY, T) Bot( "sendMessage", { "chat_id": chatID, "text": tx, "reply_to_message_id": message.message_id, "parse_mode": "html", "disable_web_page_preview": True }) if type == "UD": R = text.split(" ")[1] userId = T.id userFn = Name(T.first_name) BY = "<a href=\"tg://user?id={}\">{}</a>".format(userId, userFn) tx = textM.format(BY, R) Bot( "sendMessage", { "chat_id": chatID, "text": tx, "reply_to_message_id": message.message_id, "parse_mode": "html", "disable_web_page_preview": True }) if type == "BN": userId = T.id userFn = Name(T.first_name) BY = "[{}](tg://user?id={})".format(userFn, userId) tx = textM.format(BY) if re.search(c.stC, text): Tp = "UtoB" else: Tp = "BtoU" b = json.dumps(["Corder", Lhash, userID, userId, Tp]) v = InlineKeyboardMarkup( [[InlineKeyboardButton(r.Corder, callback_data=b)]]) Bot( "sendMessage", { "chat_id": chatID, "text": tx, "reply_to_message_id": message.message_id, "parse_mode": "markdown", "disable_web_page_preview": True, "reply_markup": v }) if type == "BNN": userId = T.id userFn = Name(T.first_name) BY = "<a href=\"tg://user?id={}\">{}</a>".format(userId, userFn) tx = textM.format(BY) Bot( "sendMessage", { "chat_id": chatID, "text": tx, "reply_to_message_id": message.message_id, "parse_mode": "html", "disable_web_page_preview": True })
def gpcmd(client, message, redis): type = message.chat.type userID = message.from_user.id chatID = message.chat.id title = message.chat.title rank = isrank(redis, userID, chatID) text = message.text username = message.from_user.username if username is None: username = "******" if redis.sismember("{}Nbot:lang:ar".format(BOT_ID), chatID): lang = "ar" elif redis.sismember("{}Nbot:lang:en".format(BOT_ID), chatID): lang = "en" else: lang = "ar" moduleCMD = "lang." + lang + "-cmd" moduleREPLY = "lang." + lang + "-reply" c = importlib.import_module(moduleCMD) r = importlib.import_module(moduleREPLY) #steps if redis.hexists("{}Nbot:step".format(BOT_ID), userID): tx = redis.hget("{}Nbot:step".format(BOT_ID), userID) if text: redis.hset("{}Nbot:{}:TXreplys".format(BOT_ID, chatID), tx, text) redis.hdel("{}Nbot:step".format(BOT_ID), userID) Bot( "sendMessage", { "chat_id": chatID, "text": r.SRtext.format(tx), "reply_to_message_id": message.message_id, "parse_mode": "html" }) if message.sticker: ID = message.sticker.file_id redis.hset("{}Nbot:{}:STreplys".format(BOT_ID, chatID), tx, ID) redis.hdel("{}Nbot:step".format(BOT_ID), userID) Bot( "sendMessage", { "chat_id": chatID, "text": r.SRst.format(tx), "reply_to_message_id": message.message_id, "parse_mode": "html" }) if message.animation: ID = message.animation.file_id redis.hset("{}Nbot:{}:GFreplys".format(BOT_ID, chatID), tx, ID) redis.hdel("{}Nbot:step".format(BOT_ID), userID) Bot( "sendMessage", { "chat_id": chatID, "text": r.SRgf.format(tx), "reply_to_message_id": message.message_id, "parse_mode": "html" }) if message.voice: ID = message.voice.file_id redis.hset("{}Nbot:{}:VOreplys".format(BOT_ID, chatID), tx, ID) redis.hdel("{}Nbot:step".format(BOT_ID), userID) Bot( "sendMessage", { "chat_id": chatID, "text": r.SRvo.format(tx), "reply_to_message_id": message.message_id, "parse_mode": "html" }) ############### if text: if text == c.settingsCmd and Ckuser(message): kb = st(client, message, redis) Bot( "sendMessage", { "chat_id": chatID, "text": r.settings.format(title), "reply_to_message_id": message.message_id, "parse_mode": "html", "reply_markup": kb }) if re.search(c.bans, text): arrays = redis.smembers("{}Nbot:{}:bans".format(BOT_ID, chatID)) b = BYusers(arrays, chatID, redis, client) kb = InlineKeyboardMarkup([[ InlineKeyboardButton(r.delList.format(text), callback_data=json.dumps( ["delListbans", "", userID])) ]]) if b is not "": Bot( "sendMessage", { "chat_id": chatID, "text": r.showlist.format(text, b), "reply_to_message_id": message.message_id, "parse_mode": "markdown", "reply_markup": kb }) else: Bot( "sendMessage", { "chat_id": chatID, "text": r.listempty.format(text), "reply_to_message_id": message.message_id, "parse_mode": "markdown" }) if re.search(c.restricteds, text): arrays = redis.smembers("{}Nbot:{}:restricteds".format( BOT_ID, chatID)) b = BYusers(arrays, chatID, redis, client) kb = InlineKeyboardMarkup([[ InlineKeyboardButton(r.delList.format(text), callback_data=json.dumps( ["delListrestricteds", "", userID])) ]]) if b is not "": Bot( "sendMessage", { "chat_id": chatID, "text": r.showlist.format(text, b), "reply_to_message_id": message.message_id, "parse_mode": "markdown", "reply_markup": kb }) else: Bot( "sendMessage", { "chat_id": chatID, "text": r.listempty.format(text), "reply_to_message_id": message.message_id, "parse_mode": "markdown" }) if re.search(c.ban, text): if re.search("@", text): user = text.split("@")[1] if re.search(c.ban2, text): user = text.split(" ")[1] if message.reply_to_message: user = message.reply_to_message.from_user.id if 'user' not in locals(): return False try: getUser = client.get_users(user) #print(getUser) userId = getUser.id userFn = getUser.first_name Getrank = isrank(redis, userId, chatID) GetGprank = GPranks(userId, chatID) if Getrank == "bot": return False if GetGprank == "NoMember": Bot( "sendMessage", { "chat_id": chatID, "text": r.NoMember, "reply_to_message_id": message.message_id, "parse_mode": "html" }) if (GetGprank == "left" or GetGprank == "kicked"): Bot( "sendMessage", { "chat_id": chatID, "text": r.haveKick, "reply_to_message_id": message.message_id, "parse_mode": "html" }) elif (GetGprank == "member" or GetGprank == "restricted") and (Getrank is False or Getrank is 0): if redis.sismember("{}Nbot:{}:bans".format(BOT_ID, chatID), userId): send_msg("BNN", client, message, r.Dban, "bans", getUser, redis) else: Bot("kickChatMember", { "chat_id": chatID, "user_id": userId }) redis.sadd("{}Nbot:{}:bans".format(BOT_ID, chatID), userId) send_msg("BN", client, message, r.ban, "bans", getUser, redis) elif (GetGprank == "creator" or GetGprank == "administrator") or (Getrank != False or Getrank != 0): Bot( "sendMessage", { "chat_id": chatID, "text": r.haveRank.format(Grank( (Getrank or GetGprank), r)), "reply_to_message_id": message.message_id, "parse_mode": "html" }) except Exception as e: print("ccc", e) Bot( "sendMessage", { "chat_id": chatID, "text": r.userNocc, "reply_to_message_id": message.message_id, "parse_mode": "html" }) if re.search(c.unban, text): if re.search("@", text): user = text.split("@")[1] if re.search(c.unban2, text): user = text.split(" ")[1] if message.reply_to_message: user = message.reply_to_message.from_user.id if 'user' not in locals(): return False try: getUser = client.get_users(user) userId = getUser.id userFn = getUser.first_name Getrank = isrank(redis, userId, chatID) GetGprank = GPranks(userId, chatID) if Getrank == "bot": return False if GetGprank == "NoMember": Bot( "sendMessage", { "chat_id": chatID, "text": r.NoMember, "reply_to_message_id": message.message_id, "parse_mode": "html" }) return False if GetGprank == "kicked": Bot("unbanChatMember", { "chat_id": chatID, "user_id": userId }) redis.srem("{}Nbot:{}:bans".format(BOT_ID, chatID), userId) send_msg("BN", client, message, r.unban, "bans", getUser, redis) else: send_msg("BNN", client, message, r.Dunban, "bans", getUser, redis) except Exception as e: print(e) Bot( "sendMessage", { "chat_id": chatID, "text": r.userNocc, "reply_to_message_id": message.message_id, "parse_mode": "html" }) if re.search(c.TK, text): if re.search("@", text): user = text.split("@")[1] if re.search(c.TK2, text): user = text.split(" ")[1] if message.reply_to_message: user = message.reply_to_message.from_user.id if 'user' not in locals(): return False try: getUser = client.get_users(user) userId = getUser.id userFn = getUser.first_name Getrank = isrank(redis, userId, chatID) GetGprank = GPranks(userId, chatID) if Getrank == "bot": return False if GetGprank == "NoMember": Bot( "sendMessage", { "chat_id": chatID, "text": r.NoMember, "reply_to_message_id": message.message_id, "parse_mode": "html" }) if (GetGprank == "left" or GetGprank == "kicked"): Bot( "sendMessage", { "chat_id": chatID, "text": r.haveKick, "reply_to_message_id": message.message_id, "parse_mode": "html" }) elif (GetGprank == "restricted"): send_msg("BNN", client, message, r.haveRc, "restricteds", getUser, redis) #Bot("sendMessage",{"chat_id":chatID,"text":r.haveRc,"reply_to_message_id":message.message_id,"parse_mode":"html"}) elif GetGprank == "member" and (Getrank is False or Getrank is 0): if redis.sismember( "{}Nbot:{}:restricteds".format(BOT_ID, chatID), userId): send_msg("BNN", client, message, r.Drestricted, "restricteds", getUser, redis) else: Bot( "restrictChatMember", { "chat_id": chatID, "user_id": userId, "can_send_messages": 0, "can_send_media_messages": 0, "can_send_other_messages": 0, "can_send_polls": 0, "can_change_info": 0, "can_add_web_page_previews": 0, "can_pin_messages": 0, }) redis.sadd( "{}Nbot:{}:restricteds".format(BOT_ID, chatID), userId) send_msg("BN", client, message, r.restricted, "restricteds", getUser, redis) elif (GetGprank == "creator" or GetGprank == "administrator") or (Getrank != False or Getrank != 0): Bot( "sendMessage", { "chat_id": chatID, "text": r.haveRank.format(Grank( (Getrank or GetGprank), r)), "reply_to_message_id": message.message_id, "parse_mode": "html" }) except Exception as e: print(e) Bot( "sendMessage", { "chat_id": chatID, "text": r.userNocc, "reply_to_message_id": message.message_id, "parse_mode": "html" }) if re.search(c.unTK, text): if re.search("@", text): user = text.split("@")[1] if re.search(c.unTK2, text): user = text.split(" ")[1] if message.reply_to_message: user = message.reply_to_message.from_user.id if 'user' not in locals(): return False try: getUser = client.get_users(user) userId = getUser.id userFn = getUser.first_name Getrank = isrank(redis, userId, chatID) GetGprank = GPranks(userId, chatID) if Getrank == "bot": return False if GetGprank == "NoMember": Bot( "sendMessage", { "chat_id": chatID, "text": r.NoMember, "reply_to_message_id": message.message_id, "parse_mode": "html" }) return False if GetGprank == "restricted": Bot( "restrictChatMember", { "chat_id": chatID, "user_id": userId, "can_send_messages": 1, "can_send_media_messages": 1, "can_send_other_messages": 1, "can_send_polls": 1, "can_change_info": 1, "can_add_web_page_previews": 1, "can_pin_messages": 1, }) redis.srem("{}Nbot:{}:restricteds".format(BOT_ID, chatID), userId) send_msg("BN", client, message, r.unrestricted, "restricteds", getUser, redis) else: send_msg("BNN", client, message, r.Dunrestricted, "restricteds", getUser, redis) except Exception as e: print(e) Bot( "sendMessage", { "chat_id": chatID, "text": r.userNocc, "reply_to_message_id": message.message_id, "parse_mode": "html" }) if rank != "admin": if re.search(c.delIDC, text): redis.hdel("{}Nbot:SHOWid".format(BOT_ID), chatID) Bot( "sendMessage", { "chat_id": chatID, "text": r.Ddelid, "reply_to_message_id": message.message_id, "parse_mode": "html" }) if re.search(c.setIDC, text): tx = text.replace(c.RsetIDC, "") t = IDrank(redis, userID, chatID, r) msgs = (redis.hget("{}Nbot:{}:msgs".format(BOT_ID, chatID), userID) or 0) edits = (redis.hget("{}Nbot:{}:edits".format(BOT_ID, chatID), userID) or 0) rate = int(msgs) * 100 / 20000 v = Bot( "sendMessage", { "chat_id": chatID, "text": tx.format(us=("@" + username or "None"), id=userID, rank=t, msgs=msgs, edits=edits, rate=str(rate) + "%"), "reply_to_message_id": message.message_id, "parse_mode": "html" }) if v["ok"]: redis.hset("{}Nbot:SHOWid".format(BOT_ID), chatID, tx) Bot( "sendMessage", { "chat_id": chatID, "text": r.DsetIDShow, "reply_to_message_id": message.message_id, "parse_mode": "html" }) elif v["ok"] == False: Bot( "sendMessage", { "chat_id": chatID, "text": r.DsetSudosShowE, "reply_to_message_id": message.message_id, "parse_mode": "html" }) if re.search(c.block, text): if re.search(c.block2, text): tx = text.replace(c.RPbk, "") if redis.sismember( "{}Nbot:{}:blockTEXTs".format(BOT_ID, chatID), tx): Bot( "sendMessage", { "chat_id": chatID, "text": r.Adoneblock.format(tx), "reply_to_message_id": message.message_id, "parse_mode": "html" }) else: redis.sadd( "{}Nbot:{}:blockTEXTs".format(BOT_ID, chatID), tx) Bot( "sendMessage", { "chat_id": chatID, "text": r.Doneblock.format(tx, title), "reply_to_message_id": message.message_id, "parse_mode": "html" }) if message.reply_to_message: if message.reply_to_message.sticker: ID = message.reply_to_message.sticker.file_id if redis.sismember( "{}Nbot:{}:blockSTICKERs".format( BOT_ID, chatID), ID): Bot( "sendMessage", { "chat_id": chatID, "text": r.StA.format(title), "reply_to_message_id": message.reply_to_message.message_id, "parse_mode": "html" }) else: redis.sadd( "{}Nbot:{}:blockSTICKERs".format( BOT_ID, chatID), ID) Bot( "sendMessage", { "chat_id": chatID, "text": r.StB.format(title), "reply_to_message_id": message.reply_to_message.message_id, "parse_mode": "html" }) if message.reply_to_message.photo: ID = message.reply_to_message.photo.file_id if redis.sismember( "{}Nbot:{}:blockphotos".format(BOT_ID, chatID), ID): Bot( "sendMessage", { "chat_id": chatID, "text": r.PhA.format(title), "reply_to_message_id": message.reply_to_message.message_id, "parse_mode": "html" }) else: redis.sadd( "{}Nbot:{}:blockphotos".format(BOT_ID, chatID), ID) Bot( "sendMessage", { "chat_id": chatID, "text": r.PhB.format(title), "reply_to_message_id": message.reply_to_message.message_id, "parse_mode": "html" }) if message.reply_to_message.animation: ID = message.reply_to_message.animation.file_id if redis.sismember( "{}Nbot:{}:blockanimations".format( BOT_ID, chatID), ID): Bot( "sendMessage", { "chat_id": chatID, "text": r.GfA.format(title), "reply_to_message_id": message.reply_to_message.message_id, "parse_mode": "html" }) else: redis.sadd( "{}Nbot:{}:blockanimations".format( BOT_ID, chatID), ID) Bot( "sendMessage", { "chat_id": chatID, "text": r.GfB.format(title), "reply_to_message_id": message.reply_to_message.message_id, "parse_mode": "html" }) if re.search(c.unblock, text): if re.search(c.unblock2, text): tx = text.replace(c.RPubk, "") if redis.sismember( "{}Nbot:{}:blockTEXTs".format(BOT_ID, chatID), tx): redis.srem( "{}Nbot:{}:blockTEXTs".format(BOT_ID, chatID), tx) Bot( "sendMessage", { "chat_id": chatID, "text": r.unDoneblock.format(tx, title), "reply_to_message_id": message.message_id, "parse_mode": "html" }) else: Bot( "sendMessage", { "chat_id": chatID, "text": r.unAdoneblock.format(tx), "reply_to_message_id": message.message_id, "parse_mode": "html" }) if message.reply_to_message: if message.reply_to_message.sticker: ID = message.reply_to_message.sticker.file_id if redis.sismember( "{}Nbot:{}:blockSTICKERs".format( BOT_ID, chatID), ID): redis.srem( "{}Nbot:{}:blockSTICKERs".format( BOT_ID, chatID), ID) Bot( "sendMessage", { "chat_id": chatID, "text": r.unStB.format(title), "reply_to_message_id": message.reply_to_message.message_id, "parse_mode": "html" }) else: Bot( "sendMessage", { "chat_id": chatID, "text": r.unStA.format(title), "reply_to_message_id": message.reply_to_message.message_id, "parse_mode": "html" }) if message.reply_to_message.photo: ID = message.reply_to_message.photo.file_id if redis.sismember( "{}Nbot:{}:blockphotos".format(BOT_ID, chatID), ID): redis.srem( "{}Nbot:{}:blockphotos".format(BOT_ID, chatID), ID) Bot( "sendMessage", { "chat_id": chatID, "text": r.unPhB.format(title), "reply_to_message_id": message.reply_to_message.message_id, "parse_mode": "html" }) else: Bot( "sendMessage", { "chat_id": chatID, "text": r.unPhA.format(title), "reply_to_message_id": message.reply_to_message.message_id, "parse_mode": "html" }) if message.reply_to_message.animation: ID = message.reply_to_message.animation.file_id if redis.sismember( "{}Nbot:{}:blockanimations".format( BOT_ID, chatID), ID): redis.srem( "{}Nbot:{}:blockanimations".format( BOT_ID, chatID), ID) Bot( "sendMessage", { "chat_id": chatID, "text": r.unGfB.format(title), "reply_to_message_id": message.reply_to_message.message_id, "parse_mode": "html" }) else: Bot( "sendMessage", { "chat_id": chatID, "text": r.unGfA.format(title), "reply_to_message_id": message.reply_to_message.message_id, "parse_mode": "html" }) if re.search(c.Blocklist, text): Botuser = client.get_me().username reply_markup = InlineKeyboardMarkup([ [ InlineKeyboardButton( c.STword, url= "https://telegram.me/{}?start=showBlocklist={}={}={}" .format(Botuser, chatID, userID, "blockTEXTs")), InlineKeyboardButton( c.STgifs, url= "https://telegram.me/{}?start=showBlocklist={}={}={}" .format(Botuser, chatID, userID, "blockanimations")), ], [ InlineKeyboardButton( c.STphoto, url= "https://telegram.me/{}?start=showBlocklist={}={}={}" .format(Botuser, chatID, userID, "blockphotos")), InlineKeyboardButton( c.STsticker, url= "https://telegram.me/{}?start=showBlocklist={}={}={}" .format(Botuser, chatID, userID, "blockSTICKERs")), ] ]) Bot( "sendMessage", { "chat_id": chatID, "text": r.blocklist.format(r.blocklist2, title), "reply_to_message_id": message.message_id, "parse_mode": "html", "reply_markup": reply_markup }) if re.search(c.Replylist, text): reply_markup = InlineKeyboardMarkup( [[ InlineKeyboardButton(c.STword, callback_data=json.dumps( ["showreplylist", "", userID])), InlineKeyboardButton(c.STgifs, callback_data=json.dumps([ "showGFreplylist", "", userID ])), ], [ InlineKeyboardButton(c.STvoice, callback_data=json.dumps([ "showVOreplylist", "", userID ])), InlineKeyboardButton(c.STsticker, callback_data=json.dumps([ "showSTreplylist", "", userID ])), ]]) Bot( "sendMessage", { "chat_id": chatID, "text": r.blocklist.format(text, title), "reply_to_message_id": message.message_id, "parse_mode": "html", "reply_markup": reply_markup }) if re.search(c.FloodT, text): Nu = text.split(" ")[2] redis.hset("{}Nbot:time_ck".format(BOT_ID), chatID, Nu) Bot( "sendMessage", { "chat_id": chatID, "text": r.DoneSet.format( text.split(" ")[0] + " " + text.split(" ")[1], Nu), "reply_to_message_id": message.message_id, "parse_mode": "html" }) if re.search(c.FloodM, text): Nu = text.split(" ")[2] redis.hset("{}Nbot:max_msg".format(BOT_ID), chatID, Nu) Bot( "sendMessage", { "chat_id": chatID, "text": r.DoneSet.format( text.split(" ")[0] + " " + text.split(" ")[1], Nu), "reply_to_message_id": message.message_id, "parse_mode": "html" }) if re.search(c.STWEL, text): Wc = text.replace(c.RPwel, "") redis.hset("{}Nbot:welcome".format(BOT_ID), chatID, Wc) Bot( "sendMessage", { "chat_id": chatID, "text": r.Donewel.format(Wc), "reply_to_message_id": message.message_id, "parse_mode": "html" }) if re.search(c.STreply, text): tx = text.replace(c.RPreply, "") if redis.hexists("{}Nbot:{}:TXreplys".format(BOT_ID, chatID), tx): Bot( "sendMessage", { "chat_id": chatID, "text": r.Yrp.format(tx), "reply_to_message_id": message.message_id, "parse_mode": "html" }) elif redis.hexists("{}Nbot:{}:STreplys".format(BOT_ID, chatID), tx): Bot( "sendMessage", { "chat_id": chatID, "text": r.Yrp.format(tx), "reply_to_message_id": message.message_id, "parse_mode": "html" }) elif redis.hexists("{}Nbot:{}:GFreplys".format(BOT_ID, chatID), tx): Bot( "sendMessage", { "chat_id": chatID, "text": r.Yrp.format(tx), "reply_to_message_id": message.message_id, "parse_mode": "html" }) elif redis.hexists("{}Nbot:{}:VOreplys".format(BOT_ID, chatID), tx): Bot( "sendMessage", { "chat_id": chatID, "text": r.Yrp.format(tx), "reply_to_message_id": message.message_id, "parse_mode": "html" }) else: redis.hset("{}Nbot:step".format(BOT_ID), userID, tx) Bot( "sendMessage", { "chat_id": chatID, "text": r.Sendreply % tx, "reply_to_message_id": message.message_id, "parse_mode": "html" }) if re.search(c.DLreply, text): tx = text.replace(c.RPdreply, "") if redis.hexists("{}Nbot:{}:TXreplys".format(BOT_ID, chatID), tx): redis.hdel("{}Nbot:{}:TXreplys".format(BOT_ID, chatID), tx) Bot( "sendMessage", { "chat_id": chatID, "text": r.Drp.format(tx), "reply_to_message_id": message.message_id, "parse_mode": "html" }) elif redis.hexists("{}Nbot:{}:STreplys".format(BOT_ID, chatID), tx): redis.hdel("{}Nbot:{}:STreplys".format(BOT_ID, chatID), tx) Bot( "sendMessage", { "chat_id": chatID, "text": r.Drp.format(tx), "reply_to_message_id": message.message_id, "parse_mode": "html" }) elif redis.hexists("{}Nbot:{}:GFreplys".format(BOT_ID, chatID), tx): redis.hdel("{}Nbot:{}:GFreplys".format(BOT_ID, chatID), tx) Bot( "sendMessage", { "chat_id": chatID, "text": r.Drp.format(tx), "reply_to_message_id": message.message_id, "parse_mode": "html" }) elif redis.hexists("{}Nbot:{}:VOreplys".format(BOT_ID, chatID), tx): redis.hdel("{}Nbot:{}:GFreplys".format(BOT_ID, chatID), tx) Bot( "sendMessage", { "chat_id": chatID, "text": r.Drp.format(tx), "reply_to_message_id": message.message_id, "parse_mode": "html" }) else: Bot( "sendMessage", { "chat_id": chatID, "text": r.Norp.format(tx), "reply_to_message_id": message.message_id, "parse_mode": "html" }) if re.search(c.setname, text): name = text.replace(c.Dsetname, "") Bot("setChatTitle", {"chat_id": chatID, "title": name}) Bot( "sendMessage", { "chat_id": chatID, "text": r.Dsetname.format(name), "reply_to_message_id": message.message_id, "parse_mode": "html" }) if re.search(c.setabout, text): about = text.replace(c.Dsetabout, "") Bot("setChatDescription", { "chat_id": chatID, "description": about }) Bot( "sendMessage", { "chat_id": chatID, "text": r.Dsetabout.format(about), "reply_to_message_id": message.message_id, "parse_mode": "html" }) if re.search( c.setphoto, text ) and message.reply_to_message and message.reply_to_message.photo: ID = message.reply_to_message.photo.file_id client.set_chat_photo(chat_id=chatID, photo=ID) Bot( "sendMessage", { "chat_id": chatID, "text": r.Dsetphoto, "reply_to_message_id": message.message_id, "parse_mode": "html" }) if re.search(c.pinmsg, text) and message.reply_to_message: if not redis.sismember("{}Nbot:Lpin".format(BOT_ID), chatID): ID = message.reply_to_message.message_id Bot("pinChatMessage", {"chat_id": chatID, "message_id": ID}) redis.hset("{}Nbot:pinmsgs".format(BOT_ID), chatID, ID) Bot( "sendMessage", { "chat_id": chatID, "text": r.Dpinmsg, "reply_to_message_id": message.message_id, "parse_mode": "html" }) elif redis.sismember("{}Nbot:Lpin".format(BOT_ID), chatID) and rank == "creator": ID = message.reply_to_message.message_id Bot("pinChatMessage", {"chat_id": chatID, "message_id": ID}) redis.hset("{}Nbot:pinmsgs".format(BOT_ID), chatID, ID) Bot( "sendMessage", { "chat_id": chatID, "text": r.Dpinmsg, "reply_to_message_id": message.message_id, "parse_mode": "html" }) if re.search(c.unpinmsg, text): if not redis.sismember("{}Nbot:Lpin".format(BOT_ID), chatID): Bot("unpinChatMessage", { "chat_id": chatID, "message_id": ID }) Bot( "sendMessage", { "chat_id": chatID, "text": r.Dunpinmsg, "reply_to_message_id": message.message_id, "parse_mode": "html" }) if redis.sismember("{}Nbot:Lpin".format(BOT_ID), chatID) and rank == "creator": Bot("unpinChatMessage", { "chat_id": chatID, "message_id": ID }) Bot( "sendMessage", { "chat_id": chatID, "text": r.Dunpinmsg, "reply_to_message_id": message.message_id, "parse_mode": "html" }) if re.search(c.SETlink, text): lk = text.replace(c.RPlink, "") redis.hset("{}Nbot:links".format(BOT_ID), chatID, lk) Bot( "sendMessage", { "chat_id": chatID, "text": r.Dsetlk.format(lk), "reply_to_message_id": message.message_id, "parse_mode": "html", "disable_web_page_preview": True }) if rank != "admin" and rank != "owner": if re.search(c.deletebots, text): bots = [ x for x in client.iter_chat_members(chatID) if x.user.is_bot and x.user.id != int(BOT_ID) and x.status != "administrator" ] if bots: Bot( "sendMessage", { "chat_id": chatID, "text": r.LenBots.format(len(bots)), "reply_to_message_id": message.message_id, "parse_mode": "html" }) for u in bots: Bot( "kickChatMember", { "chat_id": chatID, "user_id": u.user.id, "until_date": int(time.time() + 60) }) time.sleep(0.3) else: Bot( "sendMessage", { "chat_id": chatID, "text": r.NoBots, "reply_to_message_id": message.message_id, "parse_mode": "html" }) if re.search(c.deleteDeleted, text): deleted = [ x for x in client.iter_chat_members(chatID) if x.user.is_deleted ] if deleted: Bot( "sendMessage", { "chat_id": chatID, "text": r.LenDeleted.format(len(deleted)), "reply_to_message_id": message.message_id, "parse_mode": "html" }) for u in deleted: Bot( "kickChatMember", { "chat_id": chatID, "user_id": u.user.id, "until_date": int(time.time() + 60) }) time.sleep(0.3) else: Bot( "sendMessage", { "chat_id": chatID, "text": r.NoDeleted, "reply_to_message_id": message.message_id, "parse_mode": "html" }) if re.search(c.Chlang, text): Bot( "sendMessage", { "chat_id": chatID, "text": r.Chlang, "reply_to_message_id": message.message_id, "parse_mode": "html", "reply_markup": Clang(client, message, redis, r) }) if re.search(c.PROadmins, text): ads = Bot("getChatAdministrators", {"chat_id": chatID}) for ad in ads['result']: userId = ad["user"]["id"] userFn = ad["user"]["first_name"] if ad['status'] == "administrator" and int(userId) != int( BOT_ID): setrank(redis, "admin", userId, chatID, "array") Bot( "sendMessage", { "chat_id": chatID, "text": r.DPROadmins, "reply_to_message_id": message.message_id, "parse_mode": "html" })