async def on_pm_s(client: Bot, message: Message): check_ban = check_is_black_list(message) if check_ban: await message.reply_text(text=IS_BLACK_LIST_ED_MESSAGE_TEXT.format( reason=check_ban.reason)) return fwded_mesg = None if message.edit_date: ym = get_chek_dmid(message.message_id) reply_to_message_id = None if ym: reply_to_message_id = ym.message_id fwded_mesg = await message.copy( chat_id=AUTH_CHANNEL, disable_notification=True, reply_to_message_id=reply_to_message_id, reply_markup=message.reply_markup) else: fwded_mesg = await message.copy(chat_id=AUTH_CHANNEL, disable_notification=True, reply_markup=message.reply_markup) # just store, we don't need to SPAM users # mimick LiveGramBot, not @LimitatiBot ..! add_user_to_db(fwded_mesg.message_id, message.from_user.id, message.message_id)
async def on_pm_s(client: Bot, message: Message): check_ban = check_is_black_list(message) if check_ban: await message.reply_text(text=IS_BLACK_LIST_ED_MESSAGE_TEXT.format( reason=check_ban.reason)) return fwded_mesg = None if message.edit_date: ym = get_chek_dmid(message.message_id) reply_to_message_id = None if ym: reply_to_message_id = ym.message_id await message.copy(chat_id=AUTH_CHANNEL, disable_notification=True, reply_to_message_id=reply_to_message_id, reply_markup=message.reply_markup) else: fwded_mesg = await message.forward(chat_id=AUTH_CHANNEL, disable_notification=True) if not fwded_mesg: return add_user_to_db(fwded_mesg.message_id, message.from_user.id, message.message_id, 0, 0)
async def on_pm_s(_, message: Message): check_ban = check_is_black_list(message) if check_ban: await message.reply_text( text=IS_BLACK_LIST_ED_MESSAGE_TEXT.format( reason=check_ban.reason ) ) return fwded_mesg = await message.forward( AUTH_CHANNEL ) await _.send_message( AUTH_CHANNEL, f"From user_id: <code>{message.from_user.id}</code>" ) # just store, we don't need to SPAM users # mimick LiveGramBot, not @LimitatiBot ..! add_user_to_db( fwded_mesg.message_id, message.from_user.id, message.message_id )
async def on_pm_s(client: Client, message: Message): user_id, reply_message_id = get_user_id( message.reply_to_message.message_id) recvd_text = ((message.text and message.text.html) or " ") + " " # TODO: investigate this wizardry cmnd_message, ban_un_reason = recvd_text.split(" ", 1) cmnd_message = cmnd_message.strip() ban_un_reason = ban_un_reason.strip() if cmnd_message == BAN_COMMAND: add_user_to_bl(user_id, ban_un_reason) black_list_message = IS_BLACK_LIST_ED_MESSAGE_TEXT.format( reason=ban_un_reason) if not ban_un_reason: black_list_message = black_list_message.split( REASON_DE_LIMIT_ER)[0] await client.send_message(chat_id=user_id, text=black_list_message, disable_web_page_preview=True, reply_markup=message.reply_markup, disable_notification=True, reply_to_message_id=reply_message_id) await message.reply_text(f"<a href='tg://user?id={user_id}'>" "user" "</a> <b>banned</b> <i>forever</i>.") elif cmnd_message == UN_BAN_COMMAND: rem_user_from_bl(user_id) black_list_message = IS_UN_BANED_MESSAGE_TEXT.format( reason=ban_un_reason) if not ban_un_reason: black_list_message = black_list_message.split( REASON_DE_LIMIT_ER)[0] await client.send_message(chat_id=user_id, text=black_list_message, disable_web_page_preview=True, reply_markup=message.reply_markup, disable_notification=True, reply_to_message_id=reply_message_id) await message.reply_text(f"<a href='tg://user?id={user_id}'>" "user" "</a> <b>unbanned</b>.") else: try: await send_message_to_user(client, message, user_id, reply_message_id) except UserIsBlocked: await message.reply_text(BOT_WS_BLOCKED_BY_USER)
async def on_pm_s(client: Bot, message: Message): check_ban = check_is_black_list(message) if check_ban: await message.reply_text( text=IS_BLACK_LIST_ED_MESSAGE_TEXT.format( reason=check_ban.reason ) ) return if SUB_CHANNEL != -100: try: await client.get_chat_member(SUB_CHANNEL, message.from_user.id) except UserNotParticipant: chat = await client.get_chat(SUB_CHANNEL) username = f" [@{chat.username}] " if chat.username else "" return await message.reply_text(f"You Need to Join {chat.title}{username} in order to Use This Bot!.") fwded_mesg = None if message.edit_date: ym = get_chek_dmid(message.message_id) reply_to_message_id = None if ym: reply_to_message_id = ym.message_id await message.copy( chat_id=AUTH_CHANNEL, disable_notification=True, reply_to_message_id=reply_to_message_id, reply_markup=message.reply_markup ) else: fwded_mesg = await message.forward( chat_id=AUTH_CHANNEL, disable_notification=True ) if not fwded_mesg: return add_user_to_db( fwded_mesg.message_id, message.from_user.id, message.message_id, 0, 0 )
async def ban_command(client: Client, message: Message): user_id, reply_message_id = get_user_id( message.reply_to_message.message_id) _, ban_reason = get_tle_mof_t(message.text) add_user_to_bl(user_id, ban_reason) black_list_message = IS_BLACK_LIST_ED_MESSAGE_TEXT.format( reason=ban_reason) if not ban_reason: black_list_message = black_list_message.split(REASON_DE_LIMIT_ER)[0] try: await client.send_message(chat_id=user_id, text=black_list_message, disable_web_page_preview=True, reply_markup=message.reply_markup, disable_notification=True, reply_to_message_id=reply_message_id) except UserIsBlocked: await message.reply_text(BOT_WS_BLOCKED_BY_USER) await message.reply_text(f"<a href='tg://user?id={user_id}'>" "user" "</a> <b>banned</b> <i>forever</i>.")