async def pm_block(client, message): if not PM_PERMIT: return if message.chat.id in AdminSettings: set_whitelist(message.chat.id, True) if not get_whitelist(message.chat.id): await client.read_history(message.chat.id) if message.text: for x in message.text.lower().split(): if x in BLACKLIST: await client.send_sticker( message.chat.id, sticker='CAADAgAD1QQAAp7kTAry1JrL3zVXSxYE', ) await message.reply('Naah im blocking you!', ) await client.block_user(message.chat.id) return if not get_req(message.chat.id): x = await client.get_inline_bot_results(BotUsername, 'engine_pm') else: x = await client.get_inline_bot_results(BotUsername, 'engine_pm') await client.send_inline_bot_result( message.chat.id, query_id=x.query_id, result_id=x.results[0].id, hide_via=True, )
async def approve_pm(_, message): if message.chat.type == 'private': set_whitelist(message.chat.id, True) else: if message.reply_to_message: set_whitelist(message.reply_to_message.from_user.id, True) else: message.delete() return await message.edit('**Approved to PM!**') await asyncio.sleep(3) await message.delete()
async def approve_pm(_, message): if message.chat.type == "private": set_whitelist(message.chat.id, True) else: if message.reply_to_message: set_whitelist(message.reply_to_message.from_user.id, True) else: message.delete() return await message.edit("**PM permission was approved!**") await asyncio.sleep(3) await message.delete()
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, "πβ")