def warns(bot: Bot, update: Update, args: List[str]): message = update.effective_message # type: Optional[Message] chat = update.effective_chat # type: Optional[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 = "ഇയാൾക്ക് {}/{} warnings ഉണ്ട്, കാരണങ്ങൾ താഴെ പറയുന്നു:".format( num_warns, limit) for reason in reasons: text += "\n - {}".format(reason) msgs = split_message(text) for msg in msgs: update.effective_message.reply_text(msg) else: update.effective_message.reply_text( "ഇയാൾക്ക് {}/{} warnings ഉണ്ട്, കാരണം ലഭ്യമല്ല.".format( num_warns, limit)) else: update.effective_message.reply_text( "ഇയാൾക്ക് warnings ഒന്നും കിട്ടിയിട്ടില്ല!")
def warns(bot: Bot, update: Update, args: List[str]): message = update.effective_message # type: Optional[Message] chat = update.effective_chat # type: Optional[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 = "This user has {}/{} warnings, for the following reasons:".format( num_warns, limit) for reason in reasons: text += "\n - {}".format(reason) msgs = split_message(text) for msg in msgs: update.effective_message.reply_text(msg) else: update.effective_message.reply_text( "User has {}/{} warnings, but no reasons for any of them.". format(num_warns, limit)) else: update.effective_message.reply_text( "This user hasn't got any warnings!")
def warns(bot: Bot, update: Update, args: List[str]): message = update.effective_message chat = update.effective_chat user_id = extract_user(message, args) or update.effective_user.id result = sql.get_warns(user_id, chat.id) num = 1 if result and result[0] != 0: num_warns, reasons = result limit, soft_warn = sql.get_warn_setting(chat.id) if reasons: text = tld(chat.id, 'warns_list_warns').format(num_warns, limit) for reason in reasons: text += "\n {}. {}".format(num, reason) num += 1 msgs = split_message(text) for msg in msgs: update.effective_message.reply_text(msg) else: update.effective_message.reply_text( tld(chat.id, 'warns_list_warns_no_reason').format(num_warns, limit)) else: update.effective_message.reply_text( tld(chat.id, 'warns_list_warns_none'))
def 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 conn = connected(context.bot, update, chat, user.id, need_admin=False) if conn: chat = dispatcher.bot.getChat(conn) chat_name = dispatcher.bot.getChat(conn).title else: if update.effective_message.chat.type == "private": send_message( update.effective_message, tl(update.effective_message, "Anda bisa lakukan command ini pada grup, bukan pada PM")) return "" chat = update.effective_chat chat_name = update.effective_message.chat.title 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, warn_mode = sql.get_warn_setting(chat.id) if reasons: if conn: text = tl( update.effective_message, "Pengguna ini memiliki {}/{} peringatan pada *{}*, untuk alasan berikut:" ).format(num_warns, limit, chat_name) else: text = tl( update.effective_message, "Pengguna ini memiliki {}/{} peringatan, untuk alasan berikut:" ).format(num_warns, limit) for reason in reasons: text += "\n - {}".format(reason) msgs = split_message(text) for msg in msgs: send_message(update.effective_message, msg, parse_mode="markdown") else: if conn: send_message( update.effective_message, tl( update.effective_message, "Pengguna ini memiliki {}/{} peringatan pada *{}*, tetapi tidak ada alasan untuk itu." ).format(num_warns, limit, chat_name), parse_mode="markdown") else: send_message( update.effective_message, tl( update.effective_message, "Pengguna ini memiliki {}/{} peringatan, tetapi tidak ada alasan untuk itu." ).format(num_warns, limit)) else: if conn: send_message( update.effective_message, tl( update.effective_message, "Pengguna ini belum mendapatkan peringatan apa pun pada *{}*!" ).format(chat_name), parse_mode="markdown") else: send_message( update.effective_message, tl(update.effective_message, "Pengguna ini belum mendapatkan peringatan apa pun!"))