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 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 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 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"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 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!")