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 blacklist(bot: Bot, update: Update, args: List[str]): msg = update.effective_message # type: Optional[Message] chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] conn = connected(bot, update, chat, user.id, need_admin=False) if not conn == False: chat_id = conn chat_name = dispatcher.bot.getChat(conn).title else: if chat.type == "private": exit(1) else: chat_id = update.effective_chat.id chat_name = chat.title filter_list = tld(chat.id, "<b>Current blacklisted words in {}:</b>\n").format(chat_name) all_blacklisted = sql.get_chat_blacklist(chat_id) if len(args) > 0 and args[0].lower() == 'copy': for trigger in all_blacklisted: filter_list += "<code>{}</code>\n".format(html.escape(trigger)) else: for trigger in all_blacklisted: filter_list += " • <code>{}</code>\n".format(html.escape(trigger)) split_text = split_message(filter_list) for text in split_text: if filter_list == tld(chat.id, "<b>Current blacklisted words in {}:</b>\n").format(chat_name): #We need to translate msg.reply_text(tld(chat.id, "There are no blacklisted messages in <b>{}</b>!").format(chat_name), parse_mode=ParseMode.HTML) return msg.reply_text(text, parse_mode=ParseMode.HTML)
def blacklist(bot: Bot, update: Update, args: List[str]): msg = update.effective_message chat = update.effective_chat user = update.effective_user conn = connected(bot, update, chat, user.id, need_admin=False) if conn: chat_id = conn chat_name = dispatcher.bot.getChat(conn).title else: if chat.type == "private": return else: chat_id = update.effective_chat.id chat_name = chat.title filter_list = tld(chat.id, "blacklist_active_list").format(chat_name) all_blacklisted = sql.get_chat_blacklist(chat_id) if len(args) > 0 and args[0].lower() == 'copy': for trigger in all_blacklisted: filter_list += "<code>{}</code>\n".format(html.escape(trigger)) else: for trigger in all_blacklisted: filter_list += " • <code>{}</code>\n".format(html.escape(trigger)) split_text = split_message(filter_list) for text in split_text: if filter_list == tld(chat.id, "blacklist_active_list").format( chat_name): #We need to translate msg.reply_text(tld(chat.id, "blacklist_no_list").format(chat_name), parse_mode=ParseMode.HTML) return msg.reply_text(text, parse_mode=ParseMode.HTML)
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) P = 1 if result and result[0] != 0: num_warns, reasons = result limit, soft_warn = sql.get_warn_setting(chat.id) text = "This user has {}/{} warnings, for the following reasons:".format( num_warns, limit) for reason in reasons: text += "\n {}. `{}`".format(P, reason) P = P + 1 msgs = split_message(text) for msg in msgs: update.effective_message.reply_text(msg, parse_mode=ParseMode.MARKDOWN) else: update.effective_message.reply_text( "This user hasn't got any warnings!")