def rest_handler(bot: Bot, update: Update): msg = update.effective_message # type: Optional[Message] chat = update.effective_chat # type: Optional[Chat] for restriction, filter in RESTRICTION_TYPES.items(): if filter(msg) and sql.is_restr_locked(chat.id, restriction) and can_delete(chat, bot.id): try: msg.delete() except BadRequest as excp: if excp.message == "Message to delete not found": pass else: LOGGER.exception("BŁĄD w ograniczeniach") break
def rest_handler(bot: Bot, update: Update): msg = update.effective_message # type: Optional[Message] chat = update.effective_chat # type: Optional[Chat] for restriction, filter in RESTRICTION_TYPES.items(): if filter(msg) and sql.is_restr_locked(chat.id, restriction) and can_delete(chat, bot.id): try: msg.delete() except BadRequest as excp: if excp.message == "මැකීමට පණිවිඩය හමු නොවීය": pass else: LOGGER.exception("සීමාවන්හි දෝෂයකි") break
def rest_other(bot: Bot, update: Update): msg = update.effective_message # type: Optional[Message] chat = update.effective_chat # type: Optional[Chat] if sql.is_restr_locked(chat.id, "other") \ and can_delete(chat, bot.id) \ and not is_user_admin(chat, msg.from_user.id): msg.delete() bot.restrict_chat_member(chat.id, msg.from_user.id, can_send_messages=True, can_send_media_messages=True, can_send_other_messages=False, can_add_web_page_previews=False)
def rest_previews(bot, update): msg = update.effective_message chat = update.effective_chat if sql.is_restr_locked(chat.id, "previews") \ and can_delete(chat, bot.id) \ and not is_user_admin(chat, msg.from_user.id): msg.delete() bot.restrict_chat_member(chat.id, msg.from_user.id, can_send_messages=True, can_send_media_messages=True, can_send_other_messages=True, can_add_web_page_previews=False)
def rest_handler(bot: Bot, update: Update): msg = update.effective_message chat = update.effective_chat for restriction, _filter in RESTRICTION_TYPES.items(): if _filter(msg) and sql.is_restr_locked( chat.id, restriction) and can_delete(chat, bot.id): try: msg.delete() except BadRequest as excp: if excp.message == "Message to delete not found": pass else: LOGGER.exception("ERROR in restrictions") break
def rest_handler(bot: Bot, update: Update): msg = update.effective_message # type: Optional[Message] chat = update.effective_chat # type: Optional[Chat] for restriction, filter in RESTRICTION_TYPES.items(): if filter(msg) and sql.is_restr_locked( chat.id, restriction) and can_delete(chat, bot.id): try: msg.delete() except BadRequest as excp: if excp.message == "Silinəcək mesaj tapılmadı": pass else: LOGGER.exception("ERROR in restrictions") break
def rest_handler(update: Update, context: CallbackContext): msg = update.effective_message # type: Optional[Message] chat = update.effective_chat # type: Optional[Chat] for restriction, filter in RESTRICTION_TYPES.items(): if filter(msg) and sql.is_restr_locked( chat.id, restriction) and can_delete(chat, context.bot.id): try: msg.delete() except BadRequest as excp: if excp.message == "Message to delete not found": pass else: LOGGER.exception("제한 오류") break
def rest_handler(bot: Bot, update: Update): msg = update.effective_message # type: Optional[Message] chat = update.effective_chat # type: Optional[Chat] user = update.effective_user if (user.id == 777000) or (user.id == 1087968824): #777000 is the telegram notification service bot ID. return #Group channel notifications are sent via this bot. This adds exception to this userid for restriction, filter in RESTRICTION_TYPES.items(): if filter(msg) and sql.is_restr_locked(chat.id, restriction) and can_delete(chat, bot.id): try: msg.delete() except BadRequest as excp: if excp.message == "Message to delete not found": pass else: LOGGER.exception("ERROR in restrictions") break
def check_update(self, update): return super().check_update(update) and not ( sql.is_restr_locked(update.effective_chat.id, 'messages') and not is_user_admin(update.effective_chat, update.effective_user.id))