def set_warn_limit(update: Update, context: CallbackContext) -> str: args = context.args chat: Optional[Chat] = update.effective_chat user: Optional[User] = update.effective_user msg: Optional[Message] = update.effective_message if args: if args[0].isdigit(): if int(args[0]) < 3: msg.reply_text("Minimum xəbərdarlıq limiti 3-dür!") else: sql.set_warn_limit(chat.id, int(args[0])) msg.reply_text("Yeni xəbərdarlıq limiti: {}".format(args[0])) return ( f"<b>{html.escape(chat.title)}:</b>\n" f"#SET_WARN_LIMIT\n" f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n" f"Set the warn limit to <code>{args[0]}</code>") else: msg.reply_text("Mənə bir rəqəm ver!") else: limit, soft_warn = sql.get_warn_setting(chat.id) msg.reply_text("Hazırki xəbərdarlıq limiti {}".format(limit)) return ""
def __chat_settings__(chat_id, user_id): num_warn_filters = sql.num_warn_chat_filters(chat_id) limit, soft_warn = sql.get_warn_setting(chat_id) return ( f"This chat has `{num_warn_filters}` warn filters. " f"It takes `{limit}` warns before the user gets *{'kicked' if soft_warn else 'banned'}*." )
def set_warn_limit(update: Update, context: CallbackContext) -> str: args = context.args chat: Optional[Chat] = update.effective_chat user: Optional[User] = update.effective_user msg: Optional[Message] = update.effective_message if args: if args[0].isdigit(): if int(args[0]) < 3: msg.reply_text("¡El lÃmite mÃnimo de advertencia es 3!") else: sql.set_warn_limit(chat.id, int(args[0])) msg.reply_text("Se actualizó el lÃmite de advertencia a {}".format(args[0])) return ( f"<b>{html.escape(chat.title)}:</b>\n" f"#SET_WARN_LIMIT\n" f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n" f"Estableció el lÃmite de advertencia en <code>{args[0]}</code>") else: msg.reply_text("¡Dame un número como argumento!") else: limit, soft_warn = sql.get_warn_setting(chat.id) msg.reply_text("El lÃmite de advertencia actual es {}".format(limit)) return ""
def warns(update: Update, context: CallbackContext): args = context.args message: Optional[Message] = update.effective_message chat: Optional[Chat] = update.effective_chat user_id = extract_user(message, args) or update.effective_user.id result = sql.get_warns(user_id, chat.id) if result and result[0] != 0: num_warns, reasons = result limit, soft_warn = sql.get_warn_setting(chat.id) if reasons: text = f"Bu istifadəçinin {num_warns}/{limit} xəbərdarlığı var, səbəblər aşağıdadır:" for reason in reasons: text += f"\n • {reason}" msgs = split_message(text) for msg in msgs: update.effective_message.reply_text(msg) else: update.effective_message.reply_text( f"Bu istifadəçinin {num_warns}/{limit} xbərdarlığı var, amma bir səbəb verilməyib." ) else: update.effective_message.reply_text("Bu istifadəçinin xəbərdarlığı yoxdur!")
def __chat_settings__(chat_id, user_id): num_warn_filters = sql.num_warn_chat_filters(chat_id) limit, soft_warn = sql.get_warn_setting(chat_id) return ( f"Bu qrupda `{num_warn_filters}` ədəd xəbərdarlıq filtri var. " f"Xəbərdarlıq limiti: `{limit}` limitə çatanlar *{'qrupdan atılacaq' if soft_warn else 'banlanacaq'}*." )
def rmwarn_cmd(update: Update, context: CallbackContext) -> str: args = context.args message: Optional[Message] = update.effective_message chat: Optional[Chat] = update.effective_chat user_id = extract_user(message, args) if user_id: warns = sql.get_warns(user_id, chat.id) if warns and warns[0] !=0: num_warns, reasons = warns limit, soft_warn = sql.get_warn_setting(chat.id) keyboard = InlineKeyboardMarkup([[ InlineKeyboardButton( "Remove warn", callback_data="rm_warn({})".format(user_id)) ]]) reply_text = f"This user has {num_warns}/{limit} warns." try: message.reply_text(reply_text, reply_markup=keyboard) except BadRequest as err: message.reply_text( reply_text, reply_markup=keyboard, quote=False) else: message.reply_text("This user doesn't have any warns.") else: message.reply_text("No user has been mentioned.") return ""
def warns(update: Update, context: CallbackContext): args = context.args message: Optional[Message] = update.effective_message chat: Optional[Chat] = update.effective_chat user_id = extract_user(message, args) or update.effective_user.id result = sql.get_warns(user_id, chat.id) if result and result[0] != 0: num_warns, reasons = result limit, soft_warn = sql.get_warn_setting(chat.id) if reasons: text = ( f"User ini sudah {num_warns}/{limit} diperingatkan, Karena alasan:" ) for reason in reasons: text += f"\n • {reason}" msgs = split_message(text) for msg in msgs: update.effective_message.reply_text(msg) else: update.effective_message.reply_text( f"User punya {num_warns}/{limit} peringatan, tapi tanpa alasan." ) else: update.effective_message.reply_text( "User ini ga punya satupun peringatan!")
def set_warn_strength(bot: Bot, update: Update, args: List[str]): chat: Optional[Chat] = update.effective_chat user: Optional[User] = update.effective_user msg: Optional[Message] = update.effective_message if args: if args[0].lower() in ("on", "yes"): sql.set_warn_strength(chat.id, False) msg.reply_text("Too many warns will now result in a Ban!") return (f"<b>{html.escape(chat.title)}:</b>\n" f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n" f"Has enabled strong warns. Users will be seriously punched.(banned)") elif args[0].lower() in ("off", "no"): sql.set_warn_strength(chat.id, True) msg.reply_text("Too many warns will now result in a normal punch! Users will be able to join again after.") return (f"<b>{html.escape(chat.title)}:</b>\n" f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n" f"Has disabled strong punches. I will use normal punch on users.") else: msg.reply_text("I only understand on/yes/no/off!") else: limit, soft_warn = sql.get_warn_setting(chat.id) if soft_warn: msg.reply_text("Warns are currently set to *punch* users when they exceed the limits.", parse_mode=ParseMode.MARKDOWN) else: msg.reply_text("Warns are currently set to *Ban* users when they exceed the limits.", parse_mode=ParseMode.MARKDOWN) return ""
def __chat_settings__(chat_id, user_id): num_warn_filters = sql.num_warn_chat_filters(chat_id) limit, soft_warn = sql.get_warn_setting(chat_id) return ( f"This chat has `{num_warn_filters}` warn filters. " f"It takes `{limit}` kullanıcı almadan önce uyarır *{'kicked' if soft_warn else 'banned'}*." )
def warns(update: Update, context: CallbackContext): args = context.args message: Optional[Message] = update.effective_message chat: Optional[Chat] = update.effective_chat user_id = extract_user(message, args) or update.effective_user.id result = sql.get_warns(user_id, chat.id) if result and result[0] != 0: num_warns, reasons = result limit, soft_warn = sql.get_warn_setting(chat.id) if reasons: text = f"This user has {num_warns}/{limit} warns, for the following reasons:" for reason in reasons: text += f"\n - {reason}" msgs = split_message(text) for msg in msgs: update.effective_message.reply_text(msg) else: update.effective_message.reply_text( f"User has {num_warns}/{limit} warns, but no reasons for any of them." ) else: update.effective_message.reply_text( "This user doesn't have any warns!")
def set_warn_limit(update: Update, context: CallbackContext) -> str: args = context.args chat: Optional[Chat] = update.effective_chat user: Optional[User] = update.effective_user msg: Optional[Message] = update.effective_message if args: if args[0].isdigit(): if int(args[0]) < 3: msg.reply_text("The minimum warn limit is 3!") else: sql.set_warn_limit(chat.id, int(args[0])) msg.reply_text("Updated the warn limit to {}".format(args[0])) return ( f"<b>{html.escape(chat.title)}:</b>\n" f"#SET_WARN_LIMIT\n" f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n" f"Set the warn limit to <code>{args[0]}</code>") else: msg.reply_text("Give me a number as an arg!") else: limit, soft_warn = sql.get_warn_setting(chat.id) msg.reply_text("The current warn limit is {}".format(limit)) return ""
def __chat_settings__(chat_id, user_id): num_warn_filters = sql.num_warn_chat_filters(chat_id) limit, soft_warn = sql.get_warn_setting(chat_id) return ( f"Este chat tiene `{num_warn_filters}` filtros de advertencia " f"Se necesita `{limit}` advierte antes de que el usuario sea *{'expulsado' if soft_warn else 'baneado'}*." )
def warns(update: Update, context: CallbackContext): args = context.args message: Optional[Message] = update.effective_message chat: Optional[Chat] = update.effective_chat user_id = extract_user(message, args) or update.effective_user.id result = sql.get_warns(user_id, chat.id) if result and result[0] != 0: num_warns, reasons = result limit, soft_warn = sql.get_warn_setting(chat.id) if reasons: text = ( f"Este usuario tiene {num_warns}/{limit} advertencias, por los siguientes motivos:" ) for reason in reasons: text += f"\n • {reason}" msgs = split_message(text) for msg in msgs: update.effective_message.reply_text(msg) else: update.effective_message.reply_text( f"El usuario tiene {num_warns}/{limit} advertencias, pero no hay motivos para ninguna de ellas." ) else: update.effective_message.reply_text("¡Este usuario no tiene ninguna advertencia!")
def set_warn_strength(update: Update, context: CallbackContext): args = context.args chat: Optional[Chat] = update.effective_chat user: Optional[User] = update.effective_user msg: Optional[Message] = update.effective_message if args: if args[0].lower() in ("on", "yes"): sql.set_warn_strength(chat.id, False) msg.reply_text( "Too many warns will now result in a Ban Carnival!!, fireworks everywhere!! " ) return ( f"<b>{html.escape(chat.title)}:</b>\n" f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n" f"Has enabled strong warns. Users will be made into rockets and launched away from the group!! Dam Fireworks everywhere!! " ) elif args[0].lower() in ("off", "no"): sql.set_warn_strength(chat.id, True) msg.reply_text( "Too many warns will now result in a normal punch! Users will be able to join again after." ) return ( f"<b>{html.escape(chat.title)}:</b>\n" f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n" f"Has disabled strong punches. I will use normal punch on users." ) else: msg.reply_text("I only understand on/yes/no/off!") else: limit, soft_warn = sql.get_warn_setting(chat.id) if soft_warn: msg.reply_text( "Warns are currently set to *punch* users when they exceed the limits.", parse_mode=ParseMode.MARKDOWN) else: msg.reply_text( "Warns are currently set to *Ban* users when they exceed the limits.", parse_mode=ParseMode.MARKDOWN) return ""
def set_warn_strength(update: Update, context: CallbackContext): args = context.args chat: Optional[Chat] = update.effective_chat user: Optional[User] = update.effective_user msg: Optional[Message] = update.effective_message if args: if args[0].lower() in ("on", "yes"): sql.set_warn_strength(chat.id, False) msg.reply_text("¡Los usuarios que lleguen al lÃmite de las advertencias ahora serán baneadas!") return ( f"<b>{html.escape(chat.title)}:</b>\n" f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n" f"Ha habilitado fuertes avisos. Los usuarios serán seriamente golpeados.(baneados)" ) elif args[0].lower() in ("off", "no"): sql.set_warn_strength(chat.id, True) msg.reply_text( "¡Los usuarios que lleguen al lÃmite de las advertencias ahora serán expulsados!/n Los usuarios podrán unirse nuevamente después." ) return ( f"<b>{html.escape(chat.title)}:</b>\n" f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n" f"Ha desactivado los golpes fuertes. Usaré el golpe normal en los usuarios." ) else: msg.reply_text("I only understand on/yes/no/off!") else: limit, soft_warn = sql.get_warn_setting(chat.id) if soft_warn: msg.reply_text( "Las advertencias están configuradas actualmente para *expulsar* a los usuarios cuando superan los lÃmites.", parse_mode=ParseMode.MARKDOWN, ) else: msg.reply_text( "Las advertencias están configuradas actualmente para *banear* usuarios cuando exceden los lÃmites.", parse_mode=ParseMode.MARKDOWN, ) return ""
def set_warn_strength(update: Update, context: CallbackContext): args = context.args chat: Optional[Chat] = update.effective_chat user: Optional[User] = update.effective_user msg: Optional[Message] = update.effective_message if args: if args[0].lower() in ("on", "yes"): sql.set_warn_strength(chat.id, False) msg.reply_text("Xəbərdarlıq limitinə çatanlar banlanacaq!") return ( f"<b>{html.escape(chat.title)}:</b>\n" f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n" f"Has enabled strong warns. Users will be seriously punched.(banned)" ) elif args[0].lower() in ("off", "no"): sql.set_warn_strength(chat.id, True) msg.reply_text( "Xəbərdarlıq limitinə çatanlar qrupdan atılacaq." ) return ( f"<b>{html.escape(chat.title)}:</b>\n" f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n" f"Has disabled strong punches. I will use normal punch on users." ) else: msg.reply_text("Mən yalnız on/yes/no/off başa düşürəm!") else: limit, soft_warn = sql.get_warn_setting(chat.id) if soft_warn: msg.reply_text( "Xəbərdarlıq limitinə çatanlar qrupdan atılacaq.", parse_mode=ParseMode.MARKDOWN) else: msg.reply_text( "Xəbərdarlıq limitinə çatanlar banlanacaq.", parse_mode=ParseMode.MARKDOWN) return ""
def set_warn_strength(update: Update, context: CallbackContext): args = context.args chat: Optional[Chat] = update.effective_chat user: Optional[User] = update.effective_user msg: Optional[Message] = update.effective_message if args: if args[0].lower() in ("on", "yes"): sql.set_warn_strength(chat.id, False) msg.reply_text("Çox xəbərdarlıq artıq qadağa ilə nəticələnəcək!") return ( f"<b>{html.escape(chat.title)}:</b>\n" f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n" f"Güclü xəbərdarlıqları təmin etdi. İstifadəçilər ciddi şəkildə yumruqlanacaq. (Ban)" ) elif args[0].lower() in ("off", "no"): sql.set_warn_strength(chat.id, True) msg.reply_text( "Artıq çox xəbərdarlıq normal bir yumruqla nəticələnəcəkdir! İstifadəçilər bundan sonra yenidən qoşula biləcəklər." ) return ( f"<b>{html.escape(chat.title)}:</b>\n" f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n" f"Güclü yumruqları əlil etdi. İstifadəçilərdə normal yumruqdan istifadə edəcəyəm." ) else: msg.reply_text("I only understand on/yes/no/off!") else: limit, soft_warn = sql.get_warn_setting(chat.id) if soft_warn: msg.reply_text( "Warns are currently set to *punch* users when they exceed the limits.", parse_mode=ParseMode.MARKDOWN) else: msg.reply_text( "Warns are currently set to *Ban* users when they exceed the limits.", parse_mode=ParseMode.MARKDOWN) return ""
def set_warn_strength(bot: Bot, update: Update, args: List[str]): chat: Optional[Chat] = update.effective_chat user: Optional[User] = update.effective_user msg: Optional[Message] = update.effective_message if args: if args[0].lower() in ("on", "yes"): sql.set_warn_strength(chat.id, False) msg.reply_text("Çok fazla uyarı artık Yasaklama ile sonuçlanacak!") return ( f"<b>{html.escape(chat.title)}:</b>\n" f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n" f"Güçlü uyarılar sağlamıştır. Kullanıcılar ciddi şekilde yumruklanacak. (Yasaklandı)" ) elif args[0].lower() in ("off", "no"): sql.set_warn_strength(chat.id, True) msg.reply_text( "Çok fazla uyarı artık normal bir yumrukla sonuçlanacak! Kullanıcılar daha sonra tekrar katılabilecek." ) return ( f"<b>{html.escape(chat.title)}:</b>\n" f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n" f"Güçlü yumrukları devre dışı bıraktı. Kullanıcılara normal yumruk kullanacağım." ) else: msg.reply_text("Sadece anlıyorum on/yes/no/off!") else: limit, soft_warn = sql.get_warn_setting(chat.id) if soft_warn: msg.reply_text( "Uyarılar şu anda sınırları aştığında * yumruk * olarak ayarlanmış durumda.", parse_mode=ParseMode.MARKDOWN) else: msg.reply_text( "Uyarılar şu anda sınırları aştığında * Yasak * olarak ayarlanmış.", parse_mode=ParseMode.MARKDOWN) return ""
def set_warn_limit(bot: Bot, update: Update, args: List[str]) -> str: chat: Optional[Chat] = update.effective_chat user: Optional[User] = update.effective_user msg: Optional[Message] = update.effective_message if args: if args[0].isdigit(): if int(args[0]) < 3: msg.reply_text("Minimum uyarı limiti:3!") else: sql.set_warn_limit(chat.id, int(args[0])) msg.reply_text("Updated the warn limit to {}".format(args[0])) return ( f"<b>{html.escape(chat.title)}:</b>\n" f"#SET_WARN_LIMIT\n" f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n" f"Uyarı sınırını <code>{args[0]}</code>") else: msg.reply_text("Arg olarak bana bir numara ver!") else: limit, soft_warn = sql.get_warn_setting(chat.id) msg.reply_text("Geçerli uyarı limiti {}".format(limit)) return ""
def warns(bot: Bot, update: Update, args: List[str]): message: Optional[Message] = update.effective_message chat: Optional[Chat] = update.effective_chat user_id = extract_user(message, args) or update.effective_user.id result = sql.get_warns(user_id, chat.id) if result and result[0] != 0: num_warns, reasons = result limit, soft_warn = sql.get_warn_setting(chat.id) if reasons: text = f"This user has {num_warns}/{limit} aşağıdaki nedenlerle uyarıyor:" for reason in reasons: text += f"\n - {reason}" msgs = split_message(text) for msg in msgs: update.effective_message.reply_text(msg) else: update.effective_message.reply_text( f"Kullanıcının {num_warns}/{limit} uyarısı var, ancak bunların hiçbir nedeni yok." ) else: update.effective_message.reply_text("Bu kullanıcının uyarısı yok!")
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 TIGERS: if warner: message.reply_text("Los tigres no pueden ser advertidos.") else: message.reply_text( "¡El tigre activó un filtro de advertencia automática! \nNo puedo advertir a los tigres, pero deberÃan evitar abusar de esto." ) return if user.id in WOLVES: if warner: message.reply_text("Los desastres de lobo son inmunes a las advertencias.") else: message.reply_text( "¡El lobo activó un filtro de advertencia automática! \nNo puedo advertir a los lobos, pero deben evitar abusar de esto." ) return if warner: warner_tag = mention_html(warner.id, warner.first_name) else: warner_tag = "Filtro de advertencia automatizado." 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"<code>â�•</code><b>Evento de advertencias</b>\n" f"<code> </code><b>• Usuario:</b> {mention_html(user.id, user.first_name)}\n" f"<code> </code><b>• Número de advertencias:</b> {limit}") else: # ban chat.kick_member(user.id) reply = ( f"<code>â�•</code><b>Evento de baneo</b>\n" f"<code> </code><b>• Usuario:</b> {mention_html(user.id, user.first_name)}\n" f"<code> </code><b>• Número de advertencias:</b> {limit}") for warn_reason in reasons: reply += f"\n - {html.escape(warn_reason)}" # message.bot.send_sticker(chat.id, BAN_STICKER) # Saitama's sticker keyboard = None log_reason = (f"<b>{html.escape(chat.title)}:</b>\n" f"#WARN_BAN\n" f"<b>Admin:</b> {warner_tag}\n" f"<b>Usuario:</b> {mention_html(user.id, user.first_name)}\n" f"<b>Razón:</b> {reason}\n" f"<b>Número de advertencias:</b> <code>{num_warns}/{limit}</code>") else: keyboard = InlineKeyboardMarkup([[ InlineKeyboardButton( "🔘 Remover advertencia", callback_data="rm_warn({})".format(user.id)) ]]) reply = ( f"<code>â�•</code><b>Evento de advertencia</b>\n" f"<code> </code><b>• Usuario:</b> {mention_html(user.id, user.first_name)}\n" f"<code> </code><b>• Número de advertencias:</b> {num_warns}/{limit}") if reason: reply += f"\n<code> </code><b>• Razón:</b> {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>Usuario:</b> {mention_html(user.id, user.first_name)}\n" f"<b>Razón:</b> {reason}\n" f"<b>Número de advertencias:</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 == "No encuentro el mensaje que respondiste.": # 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, 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!\nI 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("Nyah!! admins, They are too far to be eliminated!") return if user.id in TIGERS: if warner: message.reply_text("Blades cant be warned.") else: message.reply_text( "Nyah a blade triggered an auto warn filter!\n I can't warn balde but trysweet sama is watching!! " ) return if user.id in WOLVES: if warner: message.reply_text( "This kitty has a shield given by trysweet sama?!") else: message.reply_text( " A shield user triggered an auto warn filter!\nI can't warn them 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"<code>❕</code><b>Punch Event</b>\n" f"<code> </code><b>• User:</b> {mention_html(user.id, user.first_name)}\n" f"<code> </code><b>• Count:</b> {limit}") else: # ban chat.kick_member(user.id) reply = ( f"<code>❕</code><b>Ban Carnival</b>\n" f"<code> </code><b>• The Prey:</b> {mention_html(user.id, user.first_name)}\n" f"<code> </code><b>• Count:</b> {limit}") for warn_reason in reasons: reply += f"\n - {html.escape(warn_reason)}" # message.bot.send_sticker(chat.id, BAN_STICKER) # Saitama's sticker keyboard = None 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("🔘 Release warn", callback_data="rm_warn({})".format(user.id)) ]]) reply = ( f"<code>❕</code><b>Warn Event</b>\n" f"<code> </code><b>• User:</b> {mention_html(user.id, user.first_name)}\n" f"<code> </code><b>• Count:</b> {num_warns}/{limit}") if reason: reply += f"\n<code> </code><b>• Reason:</b> {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("Damn these admins, We cannot warn them!") return if user.id in TIGERS: if warner: message.reply_text("Tigers can't 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 WOLVES: if warner: message.reply_text("Wolf disasters are warn immune.") else: message.reply_text( "Wolf Disaster triggered an auto warn filter!\nI 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"<code>�</code><b>Punch Event</b>\n" f"<code> </code><b>• User:</b> {mention_html(user.id, user.first_name)}\n" f"<code> </code><b>• Count:</b> {limit}") else: # ban chat.kick_member(user.id) reply = ( f"<code>�</code><b>Ban Event</b>\n" f"<code> </code><b>• User:</b> {mention_html(user.id, user.first_name)}\n" f"<code> </code><b>• Count:</b> {limit}") for warn_reason in reasons: reply += f"\n - {html.escape(warn_reason)}" # message.bot.send_sticker(chat.id, BAN_STICKER) # Saitama's sticker keyboard = None 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"<code>�</code><b>Warn Event</b>\n" f"<code> </code><b>• User:</b> {mention_html(user.id, user.first_name)}\n" f"<code> </code><b>• Count:</b> {num_warns}/{limit}") if reason: reply += f"\n<code> </code><b>• Reason:</b> {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("Damn admins, They are too far to be One Punched!") 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"<code>❕</code><b>Punch Event</b>\n" f"<code> </code><b>• User:</b> {mention_html(user.id, user.first_name)}\n" f"<code> </code><b>• Count:</b> {limit}") else: # ban chat.ban_member(user.id) reply = ( f"<code>❕</code><b>Ban Event</b>\n" f"<code> </code><b>• User:</b> {mention_html(user.id, user.first_name)}\n" f"<code> </code><b>• Count:</b> {limit}") for warn_reason in reasons: reply += f"\n - {html.escape(warn_reason)}" keyboard = None 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), ), ], [ InlineKeyboardButton( text="• Rules", url=f"t.me/{dispatcher.bot.username}?start={chat.id}", ), ], ], ) reply = ( f"<code>❕</code><b>Warn Event</b>\n" f"<code> </code><b>• User:</b> {mention_html(user.id, user.first_name)}\n" f"<code> </code><b>• Count:</b> {num_warns}/{limit}") if reason: reply += f"\n<code> </code><b>• Reason:</b> {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("Damn admins, They are too far to be One Punched!") return if user.id in TIGER_USERS: if warner: message.reply_text("Kaplanlar uyarılamaz.") else: message.reply_text( "Tiger otomatik uyarı filtresini tetikledi!\nKaplanları uyaramıyorum ama bunu kötüye kullanmaktan kaçınmalılar." ) return if user.id in WHITELIST_USERS: if warner: message.reply_text("Kurt felaketleri bağışıklığı uyarıyor.") else: message.reply_text( "Kurt Felaketi otomatik uyarı filtresini tetikledi!\nKolları uyaramıyorum, ancak bunu kötüye kullanmaktan kaçınmaları gerekiyor." ) return if warner: warner_tag = mention_html(warner.id, warner.first_name) else: warner_tag = "Otomatik uyarı filtresi." 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)} normal bir yumruk ile!* " else: # ban chat.kick_member(user.id) reply = f"{limit} warnings, *Punches {mention_html(user.id, user.first_name)} normal bir yumruk ile* " 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>Kulllanıcı:</b> {mention_html(user.id, user.first_name)}\n" f"<b>Sebep:</b> {reason}\n" f"<b>Sayımları:</b> <code>{num_warns}/{limit}</code>") else: keyboard = InlineKeyboardMarkup([{ InlineKeyboardButton("Uyarıyı kaldır", 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"\nSon uyarmanın nedeni:\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>Kullanıcı:</b> {mention_html(user.id, user.first_name)}\n" f"<b>Sebep:</b> {reason}\n" f"<b>Sayımları:</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 == "Yanıt mesajı bulunamadı": # 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, They are too far to be One Punched!") return if user.id in TIGERS: if warner: message.reply_text("Pələng istifadəçilər bilməz.") else: message.reply_text( "Pələng istifadəçilərə xəbərdarlıq verə bilmərəm!" ) return if user.id in WOLVES: if warner: message.reply_text("Canavar istifadəçilərin xəbərdarlığa qarşı immuniteti var.") else: message.reply_text( "Canavar istifadəçilərin xəbərdarlığa qarşı immuniteti var." ) return if warner: warner_tag = mention_html(warner.id, warner.first_name) else: warner_tag = "Xəbərdarlıq filtri." 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"<code>❕</code><b>Qrupdan atıldı</b>\n" f"<code> </code><b>• İstifadəçi:</b> {mention_html(user.id, user.first_name)}\n" f"<code> </code><b>• Limit:</b> {limit}") else: # ban chat.kick_member(user.id) reply = ( f"<code>❕</code><b>Banlandı</b>\n" f"<code> </code><b>• İstifadəçi:</b> {mention_html(user.id, user.first_name)}\n" f"<code> </code><b>• Limit:</b> {limit}") for warn_reason in reasons: reply += f"\n - {html.escape(warn_reason)}" message.bot.send_sticker(chat.id, BAN_STICKER) # Saitama's sticker keyboard = None 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( "🔘 Xəbərdarlığı sil", callback_data="rm_warn({})".format(user.id)) ]]) reply = ( f"<code>❕</code><b>Xəbərdarlıq</b>\n" f"<code> </code><b>• İstifadəçi:</b> {mention_html(user.id, user.first_name)}\n" f"<code> </code><b>• Say/limit:</b> {num_warns}/{limit}") if reason: reply += f"\n<code> </code><b>• Səbəb:</b> {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