async def afk(_, message): if not DB_AVAILABLE: await message.edit("You haven't set up a database!") return if len(message.text.split()) >= 2: set_afk(True, message.text.split(None, 1)[1]) await message.edit( '{} is now AFK!\nReason: {}'.format( mention_markdown( message.from_user.id, message.from_user.first_name, ), message.text.split(None, 1)[1], ), ) await setbot.send_message( Owner, 'You are now AFK!\nReason: {}'.format( message.text.split(None, 1)[1], ), ) else: set_afk(True, '') await message.edit( '{} is now AFK!'.format( mention_markdown( message.from_user.id, message.from_user.first_name, ), ), ) await setbot.send_message(Owner, 'You are now AFK!') await message.stop_propagation()
async def afk_mentioned(_, message): if not DB_AVAILABLE: return global MENTIONED get = get_afk() if get and get['afk']: if '-' in str(message.chat.id): cid = str(message.chat.id)[4:] else: cid = str(message.chat.id) if cid in list(AFK_RESTIRECT, ) and int(AFK_RESTIRECT[cid], ) >= int( time.time()): return AFK_RESTIRECT[cid] = int(time.time()) + DELAY_TIME if get['reason']: await edit_or_reply( message, text='Sorry, {} is AFK!\nReason: {}'.format( mention_markdown(Owner, OwnerName), get['reason'], ), ) else: await edit_or_reply( message, text='Sorry, {} is AFK!'.format( mention_markdown(Owner, OwnerName), ), ) _, message_type = get_message_type(message) if message_type == Types.TEXT: text = message.text or message.caption else: text = message_type.name MENTIONED.append( { 'user': message.from_user.first_name, 'user_id': message.from_user.id, 'chat': message.chat.title, 'chat_id': cid, 'text': text, 'message_id': message.message_id, }, ) button = InlineKeyboard(row_width=1) button.add(InlineKeyboardButton('🔗', url=message.link)) await setbot.send_message( Owner, '{} mentioned you in {}\n\n{}\n\nTotal mentions: `{}`'.format( mention_markdown( message.from_user.id, message.from_user.first_name, ), message.chat.title, text[:3500], len(MENTIONED), ), reply_markup=button, )
async def afk_mentioned(_, message): if not DB_AVAILABLE: return global MENTIONED get = get_afk() if get and get["afk"]: if "-" in str(message.chat.id): cid = str(message.chat.id)[4:] else: cid = str(message.chat.id) if cid in list(AFK_RESTIRECT) and int(AFK_RESTIRECT[cid]) >= int( time.time()): return AFK_RESTIRECT[cid] = int(time.time()) + DELAY_TIME if get["reason"]: await edit_or_reply(message, text="Sorry, {} is AFK!\nBecause of {}".format( mention_markdown(Owner, OwnerName), get['reason'])) else: await edit_or_reply(message, text="Sorry, {} is AFK!".format( mention_markdown(Owner, OwnerName))) _, message_type = get_message_type(message) if message_type == Types.TEXT: text = message.text or message.caption else: text = message_type.name MENTIONED.append({ "user": message.from_user.first_name, "user_id": message.from_user.id, "chat": message.chat.title, "chat_id": cid, "text": text, "message_id": message.message_id, }) button = InlineKeyboardMarkup([[ InlineKeyboardButton( "Go to message", url="https://t.me/c/{}/{}".format(cid, message.message_id), ) ]]) await setbot.send_message( Owner, "{} mentioned you in {}\n\n{}\n\nTotal count: `{}`".format( mention_markdown(message.from_user.id, message.from_user.first_name), message.chat.title, text[:3500], len(MENTIONED), ), reply_markup=button, )
async def get_list_bots(client, message): replyid = None if len(message.text.split()) >= 2: chat = message.text.split(None, 1)[1] else: chat = message.chat.id grup = await client.get_chat(chat) if message.reply_to_message: replyid = message.reply_to_message.message_id getbots = client.iter_chat_members(chat) bots = [] async for a in getbots: try: nama = a.user.first_name + " " + a.user.last_name except BaseException: nama = a.user.first_name if nama is None: nama = tld("botlist_one") if a.user.is_bot: bots.append(mention_markdown(a.user.id, nama)) teks = tld("botlist_two").format(grup.title) teks += tld("botlist_three") for x in bots: teks += "│ • {}\n".format(x) teks += tld("botlist_four").format(len(bots)) if replyid: await client.send_message(message.chat.id, teks, reply_to_message_id=replyid) else: await edit_or_reply(message, text=teks)
async def dc_id_check(_, message): user = message.from_user if message.reply_to_message: if message.reply_to_message.forward_from: dc_id = message.reply_to_message.forward_from.dc_id user = mention_markdown( message.reply_to_message.forward_from.id, message.reply_to_message.forward_from.first_name, ) else: dc_id = message.reply_to_message.from_user.dc_id user = mention_markdown( message.reply_to_message.from_user.id, message.reply_to_message.from_user.first_name, ) else: dc_id = user.dc_id user = mention_markdown( message.from_user.id, message.from_user.first_name, ) if dc_id == 1: text = "{}'s assigned DC is **DC1**, **MIA, Miami FL, USA**".format( user, ) elif dc_id == 2: text = "{}'s assigned DC is **DC2**, **AMS, Amsterdam, NL**".format( user, ) elif dc_id == 3: text = "{}'s assigned DC is **DC3**, **MIA, Miami FL, USA**".format( user, ) elif dc_id == 4: text = "{}'s assigned DC is **DC4**, **AMS, Amsterdam, NL**".format( user, ) elif dc_id == 5: text = "{}'s assigned DC is **DC5**, **SIN, Singapore, SG**".format( user, ) else: text = f"{user}'s assigned DC is **unknown**" await edit_or_reply(message, text=text)
async def afk(_, message): if not DB_AVAILABLE: await message.edit("Your database is not avaiable!") return if len(message.text.split()) >= 2: set_afk(True, message.text.split(None, 1)[1]) await message.edit("{} is now AFK!\nBecause of {}".format( mention_markdown(message.from_user.id, message.from_user.first_name), message.text.split(None, 1)[1], )) await setbot.send_message( Owner, "You are now AFK!\nBecause of {}".format( message.text.split(None, 1)[1]), ) else: set_afk(True, "") await message.edit("{} is now AFK!".format( mention_markdown(message.from_user.id, message.from_user.first_name))) await setbot.send_message(Owner, "You are now AFK!") await message.stop_propagation()
async def adminlist(client, message): creator = [] admin = [] badmin = [] replyid = None toolong = False if len(message.text.split()) >= 2: chat = message.text.split(None, 1)[1] else: chat = message.chat.id grup = await client.get_chat(chat) if message.reply_to_message: replyid = message.reply_to_message.message_id alladmins = client.iter_chat_members(chat, filter="administrators") async for a in alladmins: try: nama = a.user.first_name + " " + a.user.last_name except BaseException: nama = a.user.first_name if nama is None: nama = "☠️ Deleted account" if a.status == "administrator": if a.user.is_bot: badmin.append(mention_markdown(a.user.id, nama)) else: admin.append(mention_markdown(a.user.id, nama)) elif a.status == "creator": creator.append(mention_markdown(a.user.id, nama)) admin.sort() badmin.sort() totaladmins = len(creator) + len(admin) + len(badmin) teks = tld("adminlist_one").format(grup.title) for x in creator: teks += "│ • {}\n".format(x) if len(teks) >= 4096: await message.reply(message.chat.id, teks, reply_to_message_id=replyid) teks = "" toolong = True teks += tld("adminlist_two").format(len(admin)) for x in admin: teks += "│ • {}\n".format(x) if len(teks) >= 4096: await message.reply(teks) teks = "" toolong = True teks += tld("adminlist_three").format(len(badmin)) for x in badmin: teks += "│ • {}\n".format(x) if len(teks) >= 4096: await message.reply(message.chat.id, teks, reply_to_message_id=replyid) teks = "" toolong = True teks += tld("adminlist_four").format(totaladmins) if toolong: await message.reply(message.chat.id, teks, reply_to_message_id=replyid) else: await edit_or_reply(message, text=teks)
async def pm_button(client, query): print(query) if not PM_PERMIT: return if (query.from_user.id in AdminSettings and not re.match('engine_pm_apr', query.data) and not re.match('engine_pm_blk', query.data)): await client.answer_callback_query( query.id, "You shouln't click this.", show_alert=False, ) return if re.match('engine_pm_block', query.data): await app.send_sticker( query.from_user.id, sticker='CAADAgAD1QQAAp7kTAry1JrL3zVXSxYE', ) await setbot.edit_inline_text( query.from_user.id, 'Sorry, no cash for today.\nGoodbye!', ) await app.block_user(query.from_user.id) elif re.match('engine_pm_nope', query.data): await setbot.edit_inline_text(query.inline_message_id, '👍') await app.send_message( query.from_user.id, 'Hello, please wait for a reply from my master, thank you.', ) buttons = InlineKeyboard(row_width=2) buttons.add( InlineKeyboardButton( 'Approve', callback_data=f'engine_pm_apr-{query.from_user.id}', ), InlineKeyboardButton( 'Block', callback_data=f'engine_pm_blk-{query.from_user.id}', ), ) pm_bot_mention = mention_markdown( query.from_user.id, query.from_user.first_name, ) pm_bot_message = f'~{pm_bot_mention} want to contact you~' await setbot.send_message( NOTIFY_ID, pm_bot_message, reply_markup=buttons, ) set_req(query.from_user.id, True) elif re.match('engine_pm_report', query.data): await setbot.edit_inline_text(query.inline_message_id, '👍') await app.send_message( query.from_user.id, 'Hello, if you want to report any bugs, visit @NanaBotSupport.', ) elif re.match('engine_pm_none', query.data): await setbot.edit_inline_text(query.inline_message_id, '👍') await app.send_message( query.from_user.id, 'Alright then', ) elif re.match('engine_pm_apr', query.data): target = query.data.split('-')[1] await query.message.edit_text(f'[Approved to PM]({target})') await app.send_message( target, 'Hello, this is **Nana**, my master approved you to PM.', ) set_whitelist(int(target), True) elif re.match(r'engine_pm_blk', query.data): target = query.data.split('-')[1] await query.message.edit_text('That user was blocked ~') await app.send_message( target, 'Hello, you have been blocked.\nSorry about this!', ) await app.block_user(target) else: await setbot.edit_inline_text(query.inline_message_id, '🙆')
async def pm_button(client, query): print(query) if not PM_PERMIT: return if (query.from_user.id in AdminSettings and not re.match("engine_pm_apr", query.data) and not re.match("engine_pm_blk", query.data)): await client.answer_callback_query(query.id, "No, you can't click by yourself", show_alert=False) return if re.match("engine_pm_block", query.data): await app.send_sticker(query.from_user.id, sticker="CAADAgAD1QQAAp7kTAry1JrL3zVXSxYE") await setbot.edit_inline_text( query.from_user.id, "Sorry, No cash.\nGoodbye!", ) await app.block_user(query.from_user.id) elif re.match("engine_pm_nope", query.data): await setbot.edit_inline_text(query.inline_message_id, "👍") await app.send_message( query.from_user.id, "Hello, please wait for a reply from my master, thank you", ) buttons = InlineKeyboardMarkup([[ InlineKeyboardButton( "Approve", callback_data=f"engine_pm_apr-{query.from_user.id}"), InlineKeyboardButton( "Block", callback_data=f"engine_pm_blk-{query.from_user.id}"), ]]) pm_bot_mention = mention_markdown(query.from_user.id, query.from_user.first_name) pm_bot_message = f"{pm_bot_mention} want to contact you~" await setbot.send_message(NOTIFY_ID, pm_bot_message, reply_markup=buttons) set_req(query.from_user.id, True) elif re.match("engine_pm_report", query.data): await setbot.edit_inline_text(query.inline_message_id, "👍") await app.send_message( query.from_user.id, "Hello, if you want to report any bugs, visit @NanaBotSupport", ) elif re.match("engine_pm_none", query.data): await setbot.edit_inline_text(query.inline_message_id, "👍") await app.send_message( query.from_user.id, "Alright then", ) elif re.match("engine_pm_apr", query.data): target = query.data.split("-")[1] await query.message.edit_text(f"[Approved for PM]({target})") await app.send_message( target, "Hello, this is **Nana**, my master approved you to PM.") set_whitelist(int(target), True) elif re.match(r"engine_pm_blk", query.data): target = query.data.split("-")[1] await query.message.edit_text("That user was blocked ~") await app.send_message( target, "Hello, You have been Blocked.\nSorry for this!", ) await app.block_user(target) else: await setbot.edit_inline_text(query.inline_message_id, "🙆")