async def set_no_log_p_m(event): if Config.PM_LOGGR_BOT_API_ID is not None: reason = event.pattern_match.group(1) chat = await event.get_chat() if event.is_private: if no_log_pms_sql.is_approved(chat.id): no_log_pms_sql.disapprove(chat.id) await event.edit("Will Log Messages from this chat") await asyncio.sleep(3) await event.delete()
async def set_no_log_p_m(event): if Config.PM_LOGGR_BOT_API_ID is not None: global replied_user replied_user = await event.client(GetFullUserRequest(event.chat_id)) firstname = replied_user.user.first_name reason = event.pattern_match.group(1) chat = await event.get_chat() if event.is_private: if no_log_pms_sql.is_approved(chat.id): no_log_pms_sql.disapprove(chat.id) await event.edit( "Will Log Messages from [{}](tg://user?id={})".format( firstname, chat.id))
async def on_new_private_message(event): if Config.PM_LOGGR_BOT_API_ID is None: return if not event.is_private: return message_text = event.message.message message_media = event.message.media message_id = event.message.id message_to_id = event.message.to_id chat_id = event.chat_id # logger.info(chat_id) current_message_text = message_text.lower() if BAALAJI_TG_USER_BOT in current_message_text or \ TG_COMPANION_USER_BOT in current_message_text or \ UNIBORG_USER_BOT_NO_WARN in current_message_text: # userbot's should not reply to other userbot's # https://core.telegram.org/bots/faq#why-doesn-39t-my-bot-see-messages-from-other-bots return sender = await borg.get_entity(chat_id) if chat_id == borg.uid: # don't log Saved Messages return if sender.bot: # don't log bots return if sender.verified: # don't log verified accounts return if not pmpermit_sql.is_approved(chat_id): # pm permit await do_pm_permit_action(chat_id, event) if not no_log_pms_sql.is_approved(chat_id): # log pms await do_log_pm_action(chat_id, message_text, message_media)