def reset_warns(bot: Bot, update: Update, args: List[str]) -> str: message = update.effective_message # type: Optional[Message] chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] user_id = extract_user(message, args) if user_id: sql.reset_warns(user_id, chat.id) message.reply_text("Ammonimenti resettati!") warned = chat.get_member(user_id).user return ( "<b>{}:</b>" "\n#RESETWARNS" "\n<b>Admin:</b> {}" "\n<b>Utente:</b> {} (<code>{}</code>)".format( html.escape(chat.title), mention_html(user.id, user.first_name), mention_html(warned.id, warned.first_name), warned.id, ) ) else: message.reply_text("Nessun utente è stato designato!") return ""
def reset_warns(update: Update, context: CallbackContext) -> str: if not check_perms(update, 1): return bot, args = context.bot, context.args message = update.effective_message # type: Optional[Message] chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] user_id = extract_user(message, args) if user_id: sql.reset_warns(user_id, chat.id) message.reply_text("Warnings have been reset!") warned = chat.get_member(user_id).user return ("<b>{}:</b>" "\n#RESETWARNS" "\n<b>Admin:</b> {}" "\n<b>User:</b> {} (<code>{}</code>)".format( html.escape(chat.title), mention_html(user.id, user.first_name), mention_html(warned.id, warned.first_name), warned.id, )) message.reply_text("No user has been designated!") return ""
def reset_warns(bot: Bot, update: Update, args: List[str]) -> str: message = update.effective_message # type: Optional[Message] chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] user_id = extract_user(message, args) if user_id: sql.reset_warns(user_id, chat.id) message.reply_text( "Warnings р┤Тр┤Хр╡Нр┤Хр╡Ж reset р┤Ър╡Жр┤пр╡Нр┤др┤┐р┤Яр╡Нр┤Яр╡Бр┤гр╡Нр┤Яр╡Н!" ) warned = chat.get_member(user_id).user return "<b>{}:</b>" \ "\n#RESETWARNS" \ "\n<b>Admin:</b> {}" \ "\n<b>User:</b> {} (<code>{}</code>)".format(html.escape(chat.title), mention_html(user.id, user.first_name), mention_html(warned.id, warned.first_name), warned.id) else: message.reply_text( "р┤Жр┤░р╡Бр┤Яр╡Ж warnings р┤Жр┤гр╡Н reset р┤Ър╡Жр┤пр╡Нр┤пр╡Зр┤гр╡Нр┤Яр┤др╡Н р┤Ор┤ир╡Нр┤ир╡Б р┤кр┤▒р┤Юр╡Нр┤Юр┤┐р┤▓р╡Нр┤▓р┤▓р╡Нр┤▓р╡Л?" ) return ""
def warn(user: User, chat: Chat, reason: str, message: Message, warner: User = None) -> str: if is_user_admin(chat, user.id): message.reply_text("Damn admins, can't even be warned!") return "" if warner: warner_tag = mention_html(warner.id, warner.first_name) else: warner_tag = "Automated warn filter." limit, soft_warn = sql.get_warn_setting(chat.id) num_warns, reasons = sql.warn_user(user.id, chat.id, reason) if num_warns >= limit: sql.reset_warns(user.id, chat.id) if soft_warn: # kick chat.unban_member(user.id) reply = "{} warnings, this user has been kicked!".format(limit) else: # ban chat.kick_member(user.id) reply = "{} warnings, this user has been banned!".format(limit) message.bot.send_sticker(chat.id, BAN_STICKER) # banhammer marie sticker keyboard = [] reason = "<b>{}:</b>" \ "\n#WARN_BAN" \ "\n<b>Admin:</b> {}" \ "\n<b>User:</b> {}" \ "\n<b>Reason:</b> {}".format(html.escape(chat.title), warner_tag, mention_html(user.id, user.first_name), user.id, reason) else: keyboard = InlineKeyboardMarkup( [[InlineKeyboardButton("Remove warn", callback_data="rm_warn({})".format(user.id))]]) reply = "{} has {}/{} warnings... watch out!".format(mention_markdown(user.id, user.first_name), num_warns, limit) if reason: reply += "\nReason for last warn:\n{}".format(escape_markdown(reason)) reason = "<b>{}:</b>" \ "\n#WARN" \ "\n<b>Admin:</b> {}" \ "\n<b>User:</b> {}" \ "\n<b>Reason:</b> {}".format(html.escape(chat.title), warner_tag, mention_html(user.id, user.first_name), reason) try: message.reply_text(reply, reply_markup=keyboard, parse_mode=ParseMode.MARKDOWN) except BadRequest as excp: if excp.message == "Reply message not found": # Do not reply message.reply_text(reply, reply_markup=keyboard, parse_mode=ParseMode.MARKDOWN, quote=False) else: raise return reason
def reset_warns(bot, update, args): message = update.effective_message chat = update.effective_chat user_id = extract_user(message, args) if user_id: sql.reset_warns(user_id, chat.id) message.reply_text("Warnings have been reset!") else: message.reply_text("No user has been designated!")
def reset_warns(bot: Bot, update: Update, args: List[str]) -> str: message = update.effective_message chat = update.effective_chat user = update.effective_user user_id = extract_user(message, args) if user_id: sql.reset_warns(user_id, chat.id) message.reply_text(tld(chat.id, 'warns_reset_success')) warned = chat.get_member(user_id).user return tld(chat.id, 'warns_reset_log_channel').format( html.escape(chat.title), mention_html(user.id, user.first_name), mention_html(warned.id, warned.first_name), warned.id) else: message.reply_text(tld(chat.id, 'common_err_no_user')) return ""
def reset_warns(bot: Bot, update: Update, args: List[str]) -> str: message = update.effective_message # type: Optional[Message] chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] user_id = extract_user(message, args) if user_id: sql.reset_warns(user_id, chat.id) message.reply_text("Warnings have been reset!") warned = chat.get_member(user_id).user return f"<b>{html.escape(chat.title)}:</b>" \ f"\n#RESETWARNS" \ f"\n<b>Admin:</b> {mention_html(user.id, user.first_name)}" \ f"\n<b>User:</b> {mention_html(warned.id, warned.first_name)} (<code>{warned.id}</code>)" else: message.reply_text("No user has been designated!") return ""
def reset_warns(bot: Bot, update: Update, args: List[str]) -> str: message: Optional[Message] = update.effective_message chat: Optional[Chat] = update.effective_chat user: Optional[User] = update.effective_user user_id = extract_user(message, args) if user_id: sql.reset_warns(user_id, chat.id) message.reply_text("Warns have been reset!") warned = chat.get_member(user_id).user return (f"<b>{html.escape(chat.title)}:</b>\n" f"#RESETWARNS\n" f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n" f"<b>User:</b> {mention_html(warned.id, warned.first_name)}") else: message.reply_text("No user has been designated!") return ""
def reset_warns(bot: Bot, update: Update, args: List[str]) -> str: message: Optional[Message] = update.effective_message chat: Optional[Chat] = update.effective_chat user: Optional[User] = update.effective_user user_id = extract_user(message, args) if user_id: sql.reset_warns(user_id, chat.id) message.reply_text("Peringatan telah disetel ulang!") warned = chat.get_member(user_id).user return ( f"<b>{html.escape(chat.title)}:</b>\n" f"#RESETWARNS\n" f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n" f"<b>Pengguna:</b> {mention_html(warned.id, warned.first_name)}") else: message.reply_text("Tidak ada pengguna yang ditunjuk!") return ""
def reset_warns(bot: Bot, update: Update, args: List[str]) -> str: message = update.effective_message # type: Optional[Message] chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] user_id = extract_user(message, args) if user_id: sql.reset_warns(user_id, chat.id) message.reply_text("താക്കീതുകൾ പഴയത് പോലെ ആക്കിയിരിക്കുന്നു!") warned = chat.get_member(user_id).user return "<b>{}:</b>" \ "\n#RESETWARNS" \ "\n<b>Admin:</b> {}" \ "\n<b>User:</b> {}".format(html.escape(chat.title), mention_html(user.id, user.first_name), mention_html(warned.id, warned.first_name)) else: message.reply_text("നിങ്ങൾ ഒരു ഉപഭോക്താവിനെ സൂചിപ്പിച്ചിട്ടില്ല") return ""
def reset_warns(bot: Bot, update: Update, args: List[str]) -> str: message = update.effective_message # type: Optional[Message] chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] user_id = extract_user(message, args) if user_id: sql.reset_warns(user_id, chat.id) message.reply_text("Warnings ഒക്കെ reset ചെയ്തിട്ടുണ്ട്!") warned = chat.get_member(user_id).user return "<b>{}:</b>" \ "\n#RESETWARNS" \ "\n<b>Admin:</b> {}" \ "\n<b>User:</b> {}".format(html.escape(chat.title), mention_html(user.id, user.first_name), mention_html(warned.id, warned.first_name)) else: message.reply_text("ആരുടെ warnings ആണ് reset ചെയ്യേണ്ടത് എന്നു പറഞ്ഞില്ലല്ലോ?") return ""
def reset_warns(bot: Bot, update: Update, args: List[str]) -> str: message = update.effective_message # type: Optional[Message] chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] user_id = extract_user(message, args) if user_id: sql.reset_warns(user_id, chat.id) message.reply_text("Uyarılar Sıfırlandı!") warned = chat.get_member(user_id).user return "<b>{}:</b>" \ "\n#RESETWARNS" \ "\n<b>Admin:</b> {}" \ "\n<b>User:</b> {}".format(html.escape(chat.title), mention_html(user.id, user.first_name), mention_html(warned.id, warned.first_name)) else: message.reply_text("Hiçbir Kullanıcı Atanmadı!") return ""
def reset_warns(bot: Bot, update: Update, args: List[str]) -> str: message = update.effective_message # type: Optional[Message] chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] user_id = extract_user(message, args) if user_id: sql.reset_warns(user_id, chat.id) message.reply_text("Warnings have been reset!") warned = chat.get_member(user_id).user return "{}:" \ "\n#RESETWARNS" \ "\n*Admin:* [{}](tg://user?id={})" \ "\n*User:* [{}](tg://user?id={})".format(escape_markdown(chat.title), escape_markdown(user.first_name), user.id, escape_markdown(warned.first_name), warned.id) else: message.reply_text("No user has been designated!") return ""
def reset_warns(bot: Bot, update: Update, args: List[str]) -> str: message = update.effective_message # type: Optional[Message] chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] user_id = extract_user(message, args) if user_id: sql.reset_warns(user_id, chat.id) message.reply_text("चेतावनी रीसेट कर दी गई हैं!") warned = chat.get_member(user_id).user return "<b>{}:</b>" \ "\n#RESETWARNS" \ "\n<b>Admin:</b> {}" \ "\n<b>User:</b> {}".format(html.escape(chat.title), mention_html(user.id, user.first_name), mention_html(warned.id, warned.first_name)) else: message.reply_text("किसी भी यूजर को टैग करें!") return ""
def reset_warns(bot: Bot, update: Update, args: List[str]) -> str: message = update.effective_message # type: Optional[Message] chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] user_id = extract_user(message, args) if user_id: sql.reset_warns(user_id, chat.id) message.reply_text("Warnings have been reset!") warned = chat.get_member(user_id).user return "<b>{}:</b>" \ "\n#RESETWARNS" \ "\n<b>Admin:</b> {}" \ "\n<b>User:</b> {}".format(html.escape(chat.title), mention_html(user.id, user.first_name), mention_html(warned.id, warned.first_name)) else: message.reply_text("කිසිදු පරිශීලකයෙකු නම් කර නැත!") return ""
def reset_warns(bot: Bot, update: Update, args: List[str]) -> str: message = update.effective_message # type: Optional[Message] chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] user_id = extract_user(message, args) if user_id: sql.reset_warns(user_id, chat.id) message.reply_text("Otrzeżenia zostały zresetowane!") warned = chat.get_member(user_id).user return "<b>{}:</b>" \ "\n#RESET_OTRZEŻEŃ" \ "\n<b>Administrator:</b> {}" \ "\n<b>Futrzak:</b> {}".format(html.escape(chat.title), mention_html(user.id, user.first_name), mention_html(warned.id, warned.first_name)) else: message.reply_text("Nie wybrano żadnego futrzaka!") return ""
def reset_warns(bot: Bot, update: Update, args: List[str]) -> str: message = update.effective_message # type: Optional[Message] chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] user_id = extract_user(message, args) if user_id: sql.reset_warns(user_id, chat.id) message.reply_text("هەموو ئاگادارکردنەوەکانی لابرا!") warned = chat.get_member(user_id).user return "<b>{}:</b>" \ "\n#RESETWARNS" \ "\n<b>Admin:</b> {}" \ "\n<b>User:</b> {} (<code>{}</code>)".format(html.escape(chat.title), mention_html(user.id, user.first_name), mention_html(warned.id, warned.first_name), warned.id) else: message.reply_text("No user has been designated!") return ""
def reset_warns(bot: Bot, update: Update, args: List[str]) -> str: message = update.effective_message # type: Optional[Message] chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] user_id = extract_user(message, args) if user_id: sql.reset_warns(user_id, chat.id) message.reply_text("Warnings have been reset!") warned = chat.get_member(user_id).user return "<b>{}:</b>" \ "\n#UYARITEMIZLE" \ "\n<b>Admin:</b> {}" \ "\n<b>Kullanıcı:</b> {} (<code>{}</code>)".format(html.escape(chat.title), mention_html(user.id, user.first_name), mention_html(warned.id, warned.first_name), warned.id) else: message.reply_text("Hiçbir kullanıcı atanmadı!") return ""
def reset_warns(bot: Bot, update: Update, args: List[str]) -> str: message = update.effective_message # type: Optional[Message] chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] user_id = extract_user(message, args) if user_id: sql.reset_warns(user_id, chat.id) message.reply_text("Warns foram resetados!") warned = chat.get_member(user_id).user return "<b>{}:</b>" \ "\n#RESETWARNS" \ "\n<b>Admin:</b> {}" \ "\n<b>Usuário:</b> {} (<code>{}</code>)".format(html.escape(chat.title), mention_html(user.id, user.first_name), mention_html(warned.id, warned.first_name), warned.id) else: message.reply_text("Nenhum usuário foi designado!") return ""
def reset_warns(bot: Bot, update: Update, args: List[str]) -> str: message = update.effective_message # type: Optional[Message] chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] user_id = extract_user(message, args) if user_id: sql.reset_warns(user_id, chat.id) message.reply_text("경고가 초기화되었어요") warned = chat.get_member(user_id).user return "<b>{}:</b>" \ "\n#경고_초기화" \ "\n<b>관리자:</b> {}" \ "\n<b>사용자:</b> {} (<code>{}</code>)".format(html.escape(chat.title), mention_html(user.id, user.first_name), mention_html(warned.id, warned.first_name), warned.id) else: message.reply_text("지정된 사용자가 없어요!") return ""
def reset_warns(bot: Bot, update: Update, args: List[str]) -> str: message = update.effective_message # type: Optional[Message] chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] user_id = extract_user(message, args) if user_id: sql.reset_warns(user_id, chat.id) message.reply_text("✅ SP telah direset") warned = chat.get_member(user_id).user return "✉️ #SP_RESET 0️⃣" \ "\n<b>• Dari:</b> {} [<code>{}</code>]" \ "\n<b>• Untuk:</b> {} [<code>{}</code>]" \ "\n<b>• Grup:</b> {} [<code>{}</code>]" \ "\n#id{}".format(mention_html(user.id, user.first_name), user.id, mention_html(warned.id, warned.first_name), warned.id, chat.title, chat.id, warned.id) else: message.reply_text("⚠️ Pengguna tidak ditemukan") return ""
def reset_warns(bot: Bot, update: Update, args: List[str]) -> str: message = update.effective_message # type: Optional[Message] chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] user_id = extract_user(message, args) if user_id: sql.reset_warns(user_id, chat.id) message.reply_text("Verwarnungen wurden zurück gesetzt!") warned = chat.get_member(user_id).user return "<b>{}:</b>" \ "\n#RESETWARNS" \ "\n<b>Admin:</b> {}" \ "\n<b>Benutzer:</b> {} (<code>{}</code>)".format(html.escape(chat.title), mention_html(user.id, user.first_name), mention_html(warned.id, warned.first_name), warned.id) else: message.reply_text("Kein Benutzer angegeben!") return ""
def reset_warns(bot: Bot, update: Update, args: List[str]) -> str: message = update.effective_message # type: Optional[Message] chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] user_id = extract_user(message, args) if user_id: sql.reset_warns(user_id, chat.id) message.reply_text("اخطار ها صفر شد!") warned = chat.get_member(user_id).user return "<b>{}:</b>" \ "\n#ریست_اخطار" \ "\n<b>توسط:</b> {}" \ "\n<b>کاربر:</b> {} (<code>{}</code>)".format(html.escape(chat.title), mention_html(user.id, user.first_name), mention_html(warned.id, warned.first_name), warned.id) else: message.reply_text("آیدیش تو دیتابیس من موجود نیست!") return ""
def button(update: Update, context: CallbackContext) -> str: bot = context.bot user = update.effective_user chat = update.effective_chat query = update.callback_query splitter = query.data.replace("report_", "").split("=") user_id = splitter[2] if splitter[1] == "kick": try: bot.kickChatMember(splitter[0], splitter[2]) bot.unbanChatMember(splitter[0], splitter[2]) query.answer("Successfully Kicked.") update.effective_message.edit_text( "User kicked by {}.".format( mention_html(user.id, user.first_name)), parse_mode=ParseMode.HTML, ) sql.reset_warns(splitter[2], splitter[0]) return "" except Exception as err: query.answer("Failed to Kick") elif splitter[1] == "remove": res = sql.remove_warn(splitter[2], splitter[0]) if res: update.effective_message.edit_text( "Warn removed by {}.".format( mention_html(user.id, user.first_name)), parse_mode=ParseMode.HTML, ) user_member = chat.get_member(user_id) return ( f"<b>{html.escape(chat.title)}:</b>\n" f"#UNWARN\n" f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n" f"<b>User:</b> {mention_html(user_member.user.id, user_member.user.first_name)}" ) else: update.effective_message.edit_text("User already has no warns.", parse_mode=ParseMode.HTML) return ""
def reset_warns(update, context): message = update.effective_message # type: Optional[Message] chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] args = context.args user_id = extract_user(message, args) if user_id: sql.reset_warns(user_id, chat.id) message.reply_text(tld(chat.id, "Warnings have been reset!")) warned = chat.get_member(user_id).user return "<b>{}:</b>" \ "\n#RESETWARNS" \ "\n<b>Admin:</b> {}" \ "\n<b>User:</b> {} (<code>{}</code>)".format(html.escape(chat.title), mention_html(user.id, user.first_name), mention_html(warned.id, warned.first_name), warned.id) else: message.reply_text(tld(chat.id, "No user has been designated!")) return ""
def warn(user_id, chat, reason, bot, message): if is_user_admin(chat, user_id): message.reply_text("Damn admins, can't even be warned!") return user_warned = sql.warn_user(user_id, chat.id, reason) if user_warned.num_warns >= 3: res = chat.kick_member(user_id) if res: bot.send_sticker(chat.id, BAN_STICKER) # banhammer marie sticker message.reply_text("3 warnings, this user has been banned!") sql.reset_warns(user_id, chat.id) else: message.reply_text("An error occurred, I couldn't ban this person!") else: keyboard = InlineKeyboardMarkup( [[InlineKeyboardButton("Remove warn", callback_data="rm_warn({})".format(user_id))]]) if reason: message.reply_text( "{}/3 warnings... watch out! Latest one was because:\n{}".format(user_warned.num_warns, reason), reply_markup=keyboard) else: message.reply_text("{}/3 warnings... watch out!".format(user_warned.num_warns), reply_markup=keyboard)
def warn(user: User, chat: Chat, reason: str, message: Message, warner: User = None) -> str: if is_user_admin(chat, user.id): # message.reply_text("Damn admins, They are too far to be One Punched!") return if user.id in TIGER_USERS: if warner: message.reply_text("Tigers cant be warned.") else: message.reply_text("Tiger triggered an auto warn filter!\n I can't warn tigers but they should avoid abusing this.") return if user.id in WHITELIST_USERS: if warner: message.reply_text("Wolf disasters are warn immune.") else: message.reply_text("Wolf Disaster triggered an auto warn filter!\n I can't warn wolves but they should avoid abusing this.") return if warner: warner_tag = mention_html(warner.id, warner.first_name) else: warner_tag = "Automated warn filter." limit, soft_warn = sql.get_warn_setting(chat.id) num_warns, reasons = sql.warn_user(user.id, chat.id, reason) if num_warns >= limit: sql.reset_warns(user.id, chat.id) if soft_warn: # punch chat.unban_member(user.id) reply = f"{limit} warnings, *Punches {mention_html(user.id, user.first_name)} with a normal punch!* " else: # ban chat.kick_member(user.id) reply = f"{limit} warnings, *Punches {mention_html(user.id, user.first_name)} with a Serious Punch* " for warn_reason in reasons: reply += f"\n - {html.escape(warn_reason)}" message.bot.send_sticker(chat.id, BAN_STICKER) # Saitama's sticker keyboard = [] log_reason = (f"<b>{html.escape(chat.title)}:</b>\n" f"#WARN_BAN\n" f"<b>Admin:</b> {warner_tag}\n" f"<b>User:</b> {mention_html(user.id, user.first_name)}\n" f"<b>Reason:</b> {reason}\n" f"<b>Counts:</b> <code>{num_warns}/{limit}</code>") else: keyboard = InlineKeyboardMarkup([{InlineKeyboardButton("Remove warn", callback_data="rm_warn({})".format(user.id))}]) reply = f"{mention_html(user.id, user.first_name)} has {num_warns}/{limit} warnings... watch out!" if reason: reply += f"\nReason for last warn:\n{html.escape(reason)}" log_reason = (f"<b>{html.escape(chat.title)}:</b>\n" f"#WARN\n" f"<b>Admin:</b> {warner_tag}\n" f"<b>User:</b> {mention_html(user.id, user.first_name)}\n" f"<b>Reason:</b> {reason}\n" f"<b>Counts:</b> <code>{num_warns}/{limit}</code>") try: message.reply_text(reply, reply_markup=keyboard, parse_mode=ParseMode.HTML) except BadRequest as excp: if excp.message == "Reply message not found": # Do not reply message.reply_text(reply, reply_markup=keyboard, parse_mode=ParseMode.HTML, quote=False) else: raise return log_reason
def warn(user: User, chat: Chat, reason: str, message: Message, warner: User = None) -> str: if is_user_admin(chat, user.id): # message.reply_text("അഡ്മിൻ ആണ്... warn ചെയ്യാൻ പറ്റില്ല!") return "" if warner: warner_tag = mention_html(warner.id, warner.first_name) else: warner_tag = "Automated warn filter." limit, soft_warn = sql.get_warn_setting(chat.id) num_warns, reasons = sql.warn_user(user.id, chat.id, reason) if num_warns >= limit: sql.reset_warns(user.id, chat.id) if soft_warn: # kick chat.unban_member(user.id) reply = "{} warnings, {} നെ എടുത്തു വെളിയിൽ കളഞ്ഞു!".format( limit, mention_html(user.id, user.first_name)) else: # ban chat.kick_member(user.id) reply = "{} warnings, {} ന് ബണ്ണ് കൊടുത്തു വിട്ടിട്ടുണ്ട്!".format( limit, mention_html(user.id, user.first_name)) for warn_reason in reasons: reply += "\n - {}".format(html.escape(warn_reason)) message.bot.send_sticker(chat.id, BAN_STICKER) # banhammer marie sticker keyboard = [] log_reason = "<b>{}:</b>" \ "\n#WARN_BAN" \ "\n<b>Admin:</b> {}" \ "\n<b>User:</b> {} (<code>{}</code>)" \ "\n<b>Reason:</b> {}"\ "\n<b>Counts:</b> <code>{}/{}</code>".format(html.escape(chat.title), warner_tag, mention_html(user.id, user.first_name), user.id, reason, num_warns, limit) else: keyboard = InlineKeyboardMarkup([[ InlineKeyboardButton("Remove warn (admin only)", callback_data="rm_warn({})".format(user.id)) ]]) reply = "{} has been WARNED! \nCount: {}/{}".format( mention_html(user.id, user.first_name), num_warns, limit) if reason: reply += "\nReason for last warn:\n{}".format(html.escape(reason)) log_reason = "<b>{}:</b>" \ "\n#WARN" \ "\n<b>Admin:</b> {}" \ "\n<b>User:</b> {} (<code>{}</code>)" \ "\n<b>Reason:</b> {}"\ "\n<b>Counts:</b> <code>{}/{}</code>".format(html.escape(chat.title), warner_tag, mention_html(user.id, user.first_name), user.id, reason, num_warns, limit) try: message.reply_text(reply, reply_markup=keyboard, parse_mode=ParseMode.HTML) except BadRequest as excp: if excp.message == "Replied message not found": # Do not reply message.reply_text(reply, reply_markup=keyboard, parse_mode=ParseMode.HTML, quote=False) else: raise return log_reason
def warn(user: User, chat: Chat, reason: str, message: Message, warner: User = None) -> str: if is_user_admin(chat, user.id): message.reply_text("⚠️ Admin tidak bisa diberi SP") return "" if warner: warner_tag = mention_html(warner.id, warner.first_name) else: warner_tag = "Automated warn filter." limit, soft_warn = sql.get_warn_setting(chat.id) num_warns, reasons = sql.warn_user(user.id, chat.id, reason) if num_warns >= 3: sql.reset_warns(user.id, chat.id) if num_warns >= limit: if soft_warn: # kick chat.unban_member(user.id) reply = "{} warnings, {} has been kicked!".format(limit, mention_html(user.id, user.first_name)) else: # ban chat.kick_member(user.id) reply = "{} warnings, {} has been banned!".format(limit, mention_html(user.id, user.first_name)) for warn_reason in reasons: reply += "\n - {}".format(html.escape(warn_reason)) message.bot.send_sticker(chat.id, BAN_STICKER) # banhammer marie sticker keyboard = [] log_reason = "<b>{}:</b>" \ "\n#WARN_BAN" \ "\n<b>Admin:</b> {}" \ "\n<b>User:</b> {}" \ "\n<b>Reason:</b> {}"\ "\n<b>Counts:</b> <code>{}/{}</code>".format(html.escape(chat.title), warner_tag, mention_html(user.id, user.first_name), reason, num_warns, limit) else: keyboard = InlineKeyboardMarkup( [[InlineKeyboardButton("❌ Batal", callback_data="rm_warn({})".format(user.id))]]) reply = "{} [<code>{}</code>] Telah Diberi SP ({} dari 3).".format(mention_html(user.id, user.first_name), user.id, num_warns) if reason: reply += "\n<b>Karena:</b> {}".format(html.escape(reason)) log_reason = "✉️ #SP ➕" \ "\n<b>• Dari:</b> {} [<code>{}</code>]" \ "\n<b>• Untuk:</b> {} [<code>{}</code>]" \ "\n<b>• Grup:</b> {} [<code>{}</code>]" \ "\n<b>• Karena:</b> {}" \ "\n<b>• Jumlah SP:</b> {}/3" \ "\n#id{}".format(warner_tag, warner.id, mention_html(user.id, user.first_name), user.id, chat.title, chat.id, reason, num_warns, user.id) try: message.reply_text(reply, reply_markup=keyboard, parse_mode=ParseMode.HTML) except BadRequest as excp: if excp.message == "Reply message not found": # Do not reply message.reply_text(reply, reply_markup=keyboard, parse_mode=ParseMode.HTML, quote=False) else: raise return log_reason
def warn(user: User, chat: Chat, reason: str, message: Message, warner: User = None) -> str: if is_user_admin(chat, user.id): message.reply_text("Damn admins, inko warn karne ke Liye jadu sikhna hoga @king_un_007 jadu sikhao bhai!") return "" if warner: warner_tag = mention_html(warner.id, warner.first_name) else: warner_tag = "Automated warn filter." limit, soft_warn = sql.get_warn_setting(chat.id) num_warns, reasons = sql.warn_user(user.id, chat.id, reason) if num_warns >= limit: sql.reset_warns(user.id, chat.id) if soft_warn: # kick chat.unban_member(user.id) reply = "{} warnings, {} Laat marke nikala gya!".format(limit, mention_html(user.id, user.first_name)) else: # ban chat.kick_member(user.id) reply = "{} warnings, {} Pehli fursat me BAN kardiya!".format(limit, mention_html(user.id, user.first_name)) for warn_reason in reasons: reply += "\n - {}".format(html.escape(warn_reason)) message.bot.send_sticker(chat.id, BAN_STICKER) # banhammer marie sticker keyboard = [] log_reason = "<b>{}:</b>" \ "\n#WARN_BAN" \ "\n<b>Admin:</b> {}" \ "\n<b>User:</b> {}" \ "\n<b>Reason:</b> {}"\ "\n<b>Counts:</b> <code>{}/{}</code>".format(html.escape(chat.title), warner_tag, mention_html(user.id, user.first_name), reason, num_warns, limit) else: keyboard = InlineKeyboardMarkup( [[InlineKeyboardButton("Remove Warning ", callback_data="rm_warn({})".format(user.id))]]) reply = "{} ke pass {}/{} warnings h ... sudharja beta!".format(mention_html(user.id, user.first_name), num_warns, limit) if reason: reply += "\nReason for last warn:\n{}".format(html.escape(reason)) log_reason = "<b>{}:</b>" \ "\n#WARN" \ "\n<b>Admin:</b> {}" \ "\n<b>User:</b> {}" \ "\n<b>Reason:</b> {}"\ "\n<b>Counts:</b> <code>{}/{}</code>".format(html.escape(chat.title), warner_tag, mention_html(user.id, user.first_name), reason, num_warns, limit) try: message.reply_text(reply, reply_markup=keyboard, parse_mode=ParseMode.HTML) except BadRequest as excp: if excp.message == "Reply message not found": # Do not reply message.reply_text(reply, reply_markup=keyboard, parse_mode=ParseMode.HTML, quote=False) else: raise return log_reason