def warns(update: Update, context: CallbackContext): args = context.args 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 = "이 사용자의 경고 횟수는 {}/{} 예요. 이유:".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( "이 사용자의 경고 횟수는 {}/{} 예요. 하지만 아무 이유가 없네요.".format( num_warns, limit)) else: update.effective_message.reply_text("이 사용자에게 경고가 없어요!")
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 = "यह यूजर के पास है {}/{} चेतावनी, निम्नलिखित कारणों के लिए:".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( "यह यूजर के पास है {}/{} चेतावनी, लेकिन उनमें से किसी के लिए कोई कारण नहीं." .format(num_warns, limit)) else: update.effective_message.reply_text( "इस यूजर को कोई चेतावनी नहीं मिली है!")
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 = "Is bane ke pas {}/{} warnings h , Ye sab VAJAH h warns ki:".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 koi reason nhu bataye m* ke bache." .format(num_warns, limit)) else: update.effective_message.reply_text( "Ye sahi insan h warning nhu h abhi tak ek bhi!")
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: 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} warnings, 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} warnings, but no reasons for any of them." ) 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 # 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 = "Bu kullanıcı aşağıdaki nedenlerle {} / {} uyarılarına sahip:".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( "Kullanıcının {} / {} uyarısı var, ancak bunların hiçbir nedeni yok." .format(num_warns, limit)) else: update.effective_message.reply_text("Bu kullanıcının hiç uyarısı yok!")
def blacklist(bot: Bot, update: Update, args: List[str]): msg = update.effective_message # type: Optional[Message] chat = update.effective_chat # type: Optional[Chat] all_blacklisted = sql.get_chat_blacklist(chat.id) filter_list = get_string("blacklist", "BASE_BLACKLIST_STRING", lang.get_lang(update.effective_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 text == BASE_BLACKLIST_STRING: msg.reply_text( get_string("blacklist", "MSG_NO_BLACKLIST", lang.get_lang( update.effective_chat.id))) # MSG_NO_BLACKLIST return msg.reply_text(text, parse_mode=ParseMode.HTML)
def blackliststicker(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 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 sticker_list = "<b>List black stickers currently in {}:</b>\n".format(chat_name) all_stickerlist = sql.get_chat_stickers(chat_id) if len(args) > 0 and args[0].lower() == 'copy': for trigger in all_stickerlist: sticker_list += "<code>{}</code>\n".format(html.escape(trigger)) elif len(args) == 0: for trigger in all_stickerlist: sticker_list += " - <code>{}</code>\n".format(html.escape(trigger)) split_text = split_message(sticker_list) for text in split_text: if sticker_list == "<b>List black stickers currently in {}:</b>\n".format(chat_name).format(chat_name): send_message(update.effective_message, "There is no blacklist sticker in <b>{}</b>!".format(chat_name), parse_mode=ParseMode.HTML) return send_message(update.effective_message, 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) 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 # 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 = "Questo utente ha {}/{} ammonimenti, per le seguenti ragioni:".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( "Questo utente ha {}/{} ammonimenti ma per nessuno di essi è indicata una ragione.".format( num_warns, limit ) ) else: update.effective_message.reply_text( "Questo utente non ha ricevuto alcun ammonimento." )
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 = "ئەم بەکارهێنەرە {}/{} ئاگادارکردنەوەی هەیە، لەبەر ئەم هۆکارانەی خوارەوە:".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( "ئەم بەکارهێنەرە {}/{} ئاگادارکردنەوەی هەیە، بەڵام هیچیان هۆکارێکی بۆ دیارینەکراوە." .format(num_warns, limit)) else: update.effective_message.reply_text("هیچ ئاگادارکردنەوەیەکی نییە!")
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(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!")
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 = "Bu istifadəçinin {}/{} xəbərdarlığı var, səbəblər aşağıda verilib:".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( "Bu istifadəçinin {}/{} xəbərdarlığı var, amma səbəb verilməyib." .format(num_warns, limit)) else: update.effective_message.reply_text( "Bu istifadəçinin xəbərdarlığı yoxdu!")
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 = "يحتوي هذا المستخدم على تحذيرات {} / {}، للأسباب التالية:".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( "المستخدم لديه {} / {} تحذيرات، ولكن لا توجد أسباب لأي منهم.". 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 # 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 = "Esse usuário tem {}/{} warns, pelos seguintes motivos:".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( "Usuário tem {}/{} warns, mas nenhuma razão para eles.".format( num_warns, limit)) else: update.effective_message.reply_text("Esse usuário não tem warns!")
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 blacklist(bot: Bot, update: Update, args: List[str]): msg = update.effective_message chat = update.effective_chat update_chat_title = chat.title message_chat_title = update.effective_message.chat.title if update_chat_title == message_chat_title: base_blacklist_string = "Current <b>blacklisted</b> words:\n" else: base_blacklist_string = f"Current <b>blacklisted</b> words in <b>{update_chat_title}</b>:\n" all_blacklisted = sql.get_chat_blacklist(chat.id) filter_list = base_blacklist_string if len(args) > 0 and args[0].lower() == 'copy': for trigger in all_blacklisted: filter_list += f"<code>{html.escape(trigger)}</code>\n" else: for trigger in all_blacklisted: filter_list += f" - <code>{html.escape(trigger)}</code>\n" split_text = split_message(filter_list) for text in split_text: if text == base_blacklist_string: if update_chat_title == message_chat_title: msg.reply_text("There are no blacklisted messages here!") else: msg.reply_text( f"There are no blacklisted messages in <b>{update_chat_title}</b>!", 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) if result and result[0] != 0: num_warns, reasons = result limit, soft_warn = sql.get_warn_setting(chat.id) if reasons: text = "این شیطون {}/{} اخطار داره ، و دلایلش هم :".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( "این شیطون {}/{} اخطار داره ولی دلیل خاصی براشون تعریف نشده.". format(num_warns, limit)) else: update.effective_message.reply_text("رفیقمون پاک پاکه!")
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 = "Dieser Benutzer hat {}/{} Verwarnungen, für die folgenden Gründe:".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( "Benutzer hat {}/{} Verwarnungen, allerdings wurde kein Grund hinterlegt" .format(num_warns, limit)) else: update.effective_message.reply_text( "Dieser Benutzer hat keine Verwarnungen!")
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 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) if result and result[0] != 0: num_warns, reasons = result limit, soft_warn = sql.get_warn_setting(chat.id) if reasons: text = "මෙම පරිශීලකයා සතුව ඇත {}/{} අනතුරු ඇඟවීම්, පහත සඳහන් හේතු නිසා:".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( "පරිශීලකයා සතුව ඇත {}/{} අනතුරු ඇඟවීම්, නමුත් ඒවායින් කිසිවක් සඳහා හේතු නොමැත." .format(num_warns, limit)) else: update.effective_message.reply_text( "මෙම පරිශීලකයාට කිසිදු අනතුරු ඇඟවීමක් ලැබී නැත!")
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 = "Bu kullanıcı {}/{} uyarıya sahip, aşağıdaki sebeplerden dolayı:".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( "Bu kullanıcı {}/{} uyarıya sahip, ama hiçbir zaman sebep belirtilmemiş." .format(num_warns, limit)) else: update.effective_message.reply_text( "Bu kullanıcının herhangi bir uyarısı yok!")
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 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"Pengguna ini memiliki {num_warns}/{limit} memperingatkan, karena alasan berikut:" ) 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"Pengguna memiliki {num_warns}/{limit} memperingatkan, tapi tidak ada alasan untuk salah satu dari mereka." ) else: update.effective_message.reply_text( "Pengguna ini tidak memiliki peringatan apa pun!")
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) user = update.effective_user warned = chat.get_member(user_id).user P = 1 if result and result[0] != 0: num_warns, reasons = result limit, soft_warn = sql.get_warn_setting(chat.id) text = "{} has {}/{} warnings, for the following reasons:".format( mention_html(warned.id, warned.first_name), num_warns, limit) for reason in reasons: text += "\n {}. <code>{}</code>".format(P, reason) P = P + 1 msgs = split_message(text) for msg in msgs: update.effective_message.reply_text(msg, parse_mode=ParseMode.HTML) else: update.effective_message.reply_text( "{} hasn't got any warnings!".format( mention_html(warned.id, warned.first_name)), parse_mode=ParseMode.HTML)
def blacklist(bot: Bot, update: Update): msg = update.effective_message # type: Optional[Message] chat = update.effective_chat # type: Optional[Chat] all_blacklisted = sql.get_chat_blacklist(chat.id) filter_list = BASE_BLACKLIST_STRING 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 text == BASE_BLACKLIST_STRING: msg.reply_text("There are no blacklisted messages here!") return msg.reply_text(text, parse_mode=ParseMode.HTML)
def warns(bot, update, args): message = update.effective_message user_id = extract_user(message, args) or update.effective_user.id warned_user = sql.get_warns(user_id, update.effective_chat.id) if warned_user and warned_user.num_warns != 0: if warned_user.reasons: text = "This user has {} warnings, for the following reasons:".format(warned_user.num_warns) for reason in warned_user.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(warned_user.num_warns)) else: update.effective_message.reply_text("This user hasn't got any warnings!")
def blacklist(update, context): chat = update.effective_chat user = update.effective_user args = context.args conn = connected(context.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 chat_name = html.escape(chat_name) filter_list = "Current blacklisted words in <b>{}</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)) # 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 == "Current blacklisted words in <b>{}</b>:\n".format( chat_name): send_message( update.effective_message, "No blacklisted words in <b>{}</b>!".format(chat_name), parse_mode=ParseMode.HTML, ) return send_message(update.effective_message, text, parse_mode=ParseMode.HTML)