def check_flood(bot: Bot, update: Update) -> str: user = update.effective_user # type: Optional[User] chat = update.effective_chat # type: Optional[Chat] msg = update.effective_message # type: Optional[Message] if not user: # ignore channels return "" # ignore admins if is_user_admin(chat, user.id): sql.update_flood(chat.id, None) return "" should_ban = sql.update_flood(chat.id, user.id) if not should_ban: return "" try: bot.restrict_chat_member(chat.id, user.id, can_send_messages=False) msg.reply_text(tld(chat.id, "I like to leave the flooding to natural disasters. But you, you were just a " "disappointment. *Muted*!")) return "<b>{}:</b>" \ "\n#MUTED" \ "\n<b>User:</b> {}" \ "\nFlooded the group.".format(html.escape(chat.title), mention_html(user.id, user.first_name)) except BadRequest: msg.reply_text(tld(chat.id, "I can't mute people here, give me permissions first! Until then, I'll disable antiflood.")) sql.set_flood(chat.id, 0) return "<b>{}:</b>" \ "\n#INFO" \ "\nDon't have mute permissions, so automatically disabled antiflood.".format(chat.title)
def check_flood(bot: Bot, update: Update) -> str: user = update.effective_user chat = update.effective_chat msg = update.effective_message if not user: # ignore channels return "" # ignore admins if is_user_admin(chat, user.id): sql.update_flood(chat.id, None) return "" should_ban = sql.update_flood(chat.id, user.id) if not should_ban: return "" try: bot.restrict_chat_member(chat.id, user.id, can_send_messages=False) msg.reply_text(tld(chat.id, "flood_mute")) return tld(chat.id, "flood_logger_success").format( html.escape(chat.title), mention_html(user.id, user.first_name)) except BadRequest: msg.reply_text(tld(chat.id, "flood_err_no_perm")) sql.set_flood(chat.id, 0) return tld(chat.id, "flood_logger_fail").format(chat.title)
def check_flood(bot: Bot, update: Update) -> str: user = update.effective_user # type: Optional[User] chat = update.effective_chat # type: Optional[Chat] msg = update.effective_message # type: Optional[Message] if not user: # ignore channels return "" # ignore admins if is_user_admin(chat, user.id): sql.update_flood(chat.id, None) return "" should_ban = sql.update_flood(chat.id, user.id) if not should_ban: return "" try: bot.restrict_chat_member(chat.id, user.id, can_send_messages=False) msg.reply_text( tld(chat.id, "Jangan spam kintil" "disappointment. *Muted*!")) return "<b>{}:</b>" \ "\n#MUTED" \ "\n<b>User:</b> {}" \ "\nSpam gapenting bgt.".format(html.escape(chat.title), mention_html(user.id, user.first_name)) except BadRequest: msg.reply_text(tld(chat.id, "Saya tidak bisa membisukan seseorang.")) sql.set_flood(chat.id, 0) return "<b>{}:</b>" \ "\n#INFO" \ "\nTidak memiliki izin mute, karena otomatis mute antiflood tidak aktif.".format(chat.title)
def check_flood(bot: Bot, update: Update) -> str: user = update.effective_user # type: Optional[User] chat = update.effective_chat # type: Optional[Chat] msg = update.effective_message # type: Optional[Message] if not user: # ignore channels return "" # ignore admins if is_user_admin(chat, user.id): sql.update_flood(chat.id, None) return "" should_ban = sql.update_flood(chat.id, user.id) if not should_ban: return "" try: getmode, getvalue = sql.get_flood_setting(chat.id) if getmode == 1: chat.kick_member(user.id) execstrings = tld(update.effective_message, "Exit!") tag = "BANNED" elif getmode == 2: chat.kick_member(user.id) chat.unban_member(user.id) execstrings = tld(update.effective_message, "Exit!") tag = "KICKED" elif getmode == 3: bot.restrict_chat_member(chat.id, user.id, can_send_messages=False) execstrings = tld(update.effective_message, "Now you are silent!") tag = "MUTED" elif getmode == 4: bantime = extract_time(msg, getvalue) chat.kick_member(user.id, until_date=bantime) execstrings = tld(update.effective_message, "Out as long {}!").format(getvalue) tag = "TBAN" elif getmode == 5: mutetime = extract_time(msg, getvalue) bot.restrict_chat_member(chat.id, user.id, until_date=mutetime, can_send_messages=False) execstrings = tld(update.effective_message, "Now you stay silent for {}!").format(getvalue) tag = "TMUTE" send_message(update.effective_message, tld(update.effective_message, "I don't like people who send successive messages. But you made me " "dissapointed. {}").format(execstrings)) return "<b>{}:</b>" \ "\n#{}" \ "\n<b>User:</b> {}" \ "\nFlooded the group.".format(tag, html.escape(chat.title), mention_html(user.id, user.first_name)) except BadRequest: send_message(update.effective_message, tld(update.effective_message, "Does not have kick permission, so automatically disables antiflood.")) sql.set_flood(chat.id, 0) return "<b>{}:</b>" \ "\n#INFO" \ "\n{}".format(chat.title, tld(update.effective_message, "Does not have kick permission, so automatically disables antiflood."))