def del_blacklist(bot: Bot, update: Update):
    chat = update.effective_chat
    message = update.effective_message
    to_match = extract_text(message)
    msg = update.effective_message
    if not to_match:
        return

    chat_filters = sql.get_chat_blacklist(chat.id)
    for trigger in chat_filters:
        pattern = r"( |^|[^\w])" + trigger + r"( |$|[^\w])"
        try:
            match = re.search(pattern, to_match, flags=re.IGNORECASE)
        except Exception:
            sql.rm_from_blacklist(chat.id, trigger)
            msg.reply_text(
                f'Removed {trigger} from blacklist because of broken regex')
            return
        if match:
            try:
                message.delete()
            except BadRequest as excp:
                if excp.message == "Message to delete not found":
                    pass
                else:
                    LOGGER.exception("Error while deleting blacklist message.")
            break
Beispiel #2
0
def unblacklist(bot: Bot, update: Update):
    msg = update.effective_message
    chat = update.effective_chat
    words = msg.text.split(None, 1)

    if len(words) > 1:
        text = words[1]
        to_unblacklist = list(set(trigger.strip() for trigger in text.split("\n") if trigger.strip()))
        successful = 0

        for trigger in to_unblacklist:
            success = sql.rm_from_blacklist(chat.id, trigger.lower())
            if success:
                successful += 1

        if len(to_unblacklist) == 1:
            if successful:
                msg.reply_text(f"Removed <code>{html.escape(to_unblacklist[0])}</code> from the blacklist!",
                               parse_mode=ParseMode.HTML)
            else:
                msg.reply_text("This isn't a blacklisted trigger...!")

        elif successful == len(to_unblacklist):
            msg.reply_text(f"Removed <code>{successful}</code> triggers from the blacklist.", parse_mode=ParseMode.HTML)

        elif not successful:
            msg.reply_text("None of these triggers exist, so they weren't removed.", parse_mode=ParseMode.HTML)

        else:
            msg.reply_text(f"Removed <code>{successful}</code> triggers from the blacklist."
                           f" {len(to_unblacklist) - successful} did not exist, so were not removed.",
                           parse_mode=ParseMode.HTML)
    else:
        msg.reply_text("Tell me which words you would like to remove from the blacklist.")
Beispiel #3
0
def unblacklist(update: Update, context: CallbackContext):
    msg = update.effective_message  # type: Optional[Message]
    chat = update.effective_chat  # type: Optional[Chat]
    words = msg.text.split(None, 1)
    if len(words) > 1:
        text = words[1]
        to_unblacklist = list({
            trigger.strip()
            for trigger in text.split("\n") if trigger.strip()
        })
        successful = 0
        for trigger in to_unblacklist:
            success = sql.rm_from_blacklist(chat.id, trigger.lower())
            if success:
                successful += 1

        if len(to_unblacklist) == 1:
            if successful:
                msg.reply_text(
                    get_string("blacklist", "MSG_REMOVED_SUCCESS",
                               lang.get_lang(update.effective_chat.id)).format(
                                   html.escape(to_unblacklist[0])),
                    parse_mode=ParseMode.HTML)  # MSG_REMOVED_SUCCESS
            else:
                msg.reply_text(
                    get_string("blacklist", "ERR_NOT_VALID_TRIGGER",
                               lang.get_lang(update.effective_chat.id))
                )  # ERR_NOT_VALID_TRIGGER

        elif successful == len(to_unblacklist):
            msg.reply_text(
                get_string("blacklist", "MSG_REMOVED_SUCCESS_MULTIPLE",
                           lang.get_lang(
                               update.effective_chat.id)).format(successful),
                parse_mode=ParseMode.HTML)  # MSG_REMOVED_SUCCESS_MULTIPLE

        elif not successful:
            msg.reply_text(
                get_string("blacklist", "ERR_NOT_VALID_TRIGGER_MULTIPLE",
                           lang.get_lang(update.effective_chat.id)).format(
                               successful,
                               len(to_unblacklist) - successful),
                parse_mode=ParseMode.HTML)  # ERR_NOT_VALID_TRIGGER_MULTIPLE

        else:
            msg.reply_text(
                get_string("blacklist", "ERR_NOT_ALL_VALID_TRIGGER",
                           lang.get_lang(update.effective_chat.id)).format(
                               successful,
                               len(to_unblacklist) - successful),
                parse_mode=ParseMode.HTML)  # ERR_NOT_ALL_VALID_TRIGGER
    else:
        msg.reply_text(
            get_string(
                "blacklist", "ERR_REMOVE_BAD_REQUEST",
                lang.get_lang(
                    update.effective_chat.id)))  # ERR_REMOVE_BAD_REQUEST
Beispiel #4
0
def unblacklist(bot: Bot, update: Update):
    msg = update.effective_message
    chat = update.effective_chat
    user = update.effective_user
    words = msg.text.split(None, 1)

    conn = connected(bot, update, chat, user.id)
    if conn:
        chat_id = conn
        chat_name = dispatcher.bot.getChat(conn).title
    else:
        chat_id = update.effective_chat.id
        if chat.type == "private":
            return
        else:
            chat_name = chat.title

    if len(words) > 1:
        text = words[1]
        to_unblacklist = list(
            set(trigger.strip() for trigger in text.split("\n")
                if trigger.strip()))
        successful = 0
        for trigger in to_unblacklist:
            success = sql.rm_from_blacklist(chat_id, trigger.lower())
            if success:
                successful += 1

        if len(to_unblacklist) == 1:
            if successful:
                msg.reply_text(tld(chat.id, "blacklist_del").format(
                    html.escape(to_unblacklist[0]), chat_name),
                               parse_mode=ParseMode.HTML)
            else:
                msg.reply_text(tld(chat.id, "blacklist_err_not_trigger"))

        elif successful == len(to_unblacklist):
            msg.reply_text(tld(chat.id, "blacklist_multi_del").format(
                successful, chat_name),
                           parse_mode=ParseMode.HTML)

        elif not successful:
            msg.reply_text(tld(chat.id,
                               "blacklist_err_multidel_no_trigger").format(
                                   successful,
                                   len(to_unblacklist) - successful),
                           parse_mode=ParseMode.HTML)

        else:
            msg.reply_text(tld(
                chat.id, "blacklist_err_multidel_some_no_trigger").format(
                    successful, chat_name,
                    len(to_unblacklist) - successful),
                           parse_mode=ParseMode.HTML)
    else:
        msg.reply_text(tld(chat.id, "blacklist_err_del_no_args"))
Beispiel #5
0
def unblacklist(bot: Bot, update: Update):
    msg = update.effective_message  # type: Optional[Message]
    chat = update.effective_chat  # type: Optional[Chat]
    words = msg.text.split(None, 1)

    user = update.effective_user
    admin = chat.get_member(int(user.id))
    if (admin.status != 'creator') and (not admin.can_delete_messages) and (
            not int(user.id) in SUDO_USERS):
        update.effective_message.reply_text(
            "You don't have sufficient permissions to restrict users!")
        return ""

    if len(words) > 1:
        text = words[1]
        to_unblacklist = list(
            set(trigger.strip() for trigger in text.split("\n")
                if trigger.strip()))
        successful = 0
        for trigger in to_unblacklist:
            success = sql.rm_from_blacklist(chat.id, trigger.lower())
            if success:
                successful += 1

        if len(to_unblacklist) == 1:
            if successful:
                msg.reply_text(
                    "Removed <code>{}</code> from the blacklist!".format(
                        html.escape(to_unblacklist[0])),
                    parse_mode=ParseMode.HTML)
            else:
                msg.reply_text("This isn't a blacklisted trigger...!")

        elif successful == len(to_unblacklist):
            msg.reply_text(
                "Removed <code>{}</code> triggers from the blacklist.".format(
                    successful),
                parse_mode=ParseMode.HTML)

        elif not successful:
            msg.reply_text(
                "None of these triggers exist, so they weren't removed.".
                format(successful,
                       len(to_unblacklist) - successful),
                parse_mode=ParseMode.HTML)

        else:
            msg.reply_text(
                "Removed <code>{}</code> triggers from the blacklist. {} did not exist, "
                "so were not removed.".format(successful,
                                              len(to_unblacklist) -
                                              successful),
                parse_mode=ParseMode.HTML)
    else:
        msg.reply_text(
            "Tell me which words you would like to remove from the blacklist.")
Beispiel #6
0
def unblacklist(update, context) -> str:
    msg = update.effective_message  # type: Optional[Message]
    chat = update.effective_chat  # type: Optional[Chat]
    words = msg.text.split(None, 1)
    if len(words) > 1:
        text = words[1]
        to_unblacklist = list(
            set(trigger.strip() for trigger in text.split("\n")
                if trigger.strip()))
        successful = 0
        for trigger in to_unblacklist:
            success = sql.rm_from_blacklist(chat, trigger.lower())
            if success:
                successful += 1

        if len(to_unblacklist) == 1:
            if successful:
                msg.reply_text(tld(
                    chat.id,
                    "Removed <code>{}</code> from the blacklist!").format(
                        html.escape(to_unblacklist[0])),
                               parse_mode='html')
            else:
                msg.reply_text(
                    tld(chat.id, "This isn't a blacklisted trigger...!"))

        elif successful == len(to_unblacklist):
            msg.reply_text(tld(
                chat.id,
                "Removed <code>{}</code> triggers from the blacklist.").format(
                    successful),
                           parse_mode='html')

        elif not successful:
            msg.reply_text(tld(
                chat.id,
                "None of these triggers exist, so they weren't removed.").
                           format(successful,
                                  len(to_unblacklist) - successful),
                           parse_mode='html')

        else:
            msg.reply_text(tld(
                chat.id,
                "Removed <code>{}</code> triggers from the blacklist. {} did not exist, "
                "so were not removed.").format(
                    successful,
                    len(to_unblacklist) - successful),
                           parse_mode='html')
    else:
        msg.reply_text(
            tld(
                chat.id,
                "Tell me which words you would like to remove from the blacklist."
            ))
Beispiel #7
0
def unblacklist(bot: Bot, update: Update):
    msg = update.effective_message  # type: Optional[Message]
    chat = update.effective_chat  # type: Optional[Chat]
    user = update.effective_user  # type: Optional[User]
    words = msg.text.split(None, 1)

    conn = connected(bot, update, chat, user.id)
    if not conn == False:
        chat_id = conn
        chat_name = dispatcher.bot.getChat(conn).title
    else:
        chat_id = update.effective_chat.id
        if chat.type == "private":
            exit(1)
        else:
            chat_name = chat.title


    if len(words) > 1:
        text = words[1]
        to_unblacklist = list(set(trigger.strip() for trigger in text.split("\n") if trigger.strip()))
        successful = 0
        for trigger in to_unblacklist:
            success = sql.rm_from_blacklist(chat_id, trigger.lower())
            if success:
                successful += 1

        if len(to_unblacklist) == 1:
            if successful:
                msg.reply_text(tld(chat.id, "Removed <code>{}</code> from the blacklist in <b>{}</b>!").format(html.escape(to_unblacklist[0]), chat_name),
                               parse_mode=ParseMode.HTML)
            else:
                msg.reply_text(tld(chat.id, "This isn't a blacklisted trigger...!"))

        elif successful == len(to_unblacklist):
            msg.reply_text(tld(chat.id, 
                "Removed <code>{}</code> triggers from the blacklist in <b>{}</b>!").format(
                    successful, chat_name), parse_mode=ParseMode.HTML)

        elif not successful:
            msg.reply_text(tld(chat.id, 
                "None of these triggers exist, so they weren't removed.").format(
                    successful, len(to_unblacklist) - successful), parse_mode=ParseMode.HTML)

        else:
            msg.reply_text(tld(chat.id, 
                "Removed <code>{}</code> triggers from the blacklist in <b>{}</b>! {} did not exist, "
                "so were not removed.").format(successful, chat_name, len(to_unblacklist) - successful),
                parse_mode=ParseMode.HTML)
    else:
        msg.reply_text(tld(chat.id, "Tell me which words you would like to remove from the blacklist."))
def unblacklist(bot: Bot, update: Update):
    msg = update.effective_message  # type: Optional[Message]
    chat = update.effective_chat  # type: Optional[Chat]
    words = msg.text.split(None, 1)
    if len(words) > 1:
        text = words[1]
        to_unblacklist = list(
            set(trigger.strip() for trigger in text.split("\n")
                if trigger.strip()))
        successful = 0
        for trigger in to_unblacklist:
            success = sql.rm_from_blacklist(chat.id, trigger.lower())
            if success:
                successful += 1

        if len(to_unblacklist) == 1:
            if successful:
                msg.reply_text(
                    "Rimosso <code>{}</code> dalla blacklist!".format(
                        html.escape(to_unblacklist[0])),
                    parse_mode=ParseMode.HTML,
                )
            else:
                msg.reply_text("Questo non è un blacklisted trigger...!")

        elif successful == len(to_unblacklist):
            msg.reply_text(
                "Rimosso il trigger <code>{}</code> dalla blacklist.".format(
                    successful),
                parse_mode=ParseMode.HTML,
            )

        elif not successful:
            msg.reply_text(
                "Nessuno di questi trigger esiste, quindi non sono stati rimossi."
                .format(successful,
                        len(to_unblacklist) - successful),
                parse_mode=ParseMode.HTML,
            )

        else:
            msg.reply_text(
                "Rimosso il trigger <code>{}</code> dalla blacklist. {} Non esistono, "
                "quindi non sono stati rimossi.".format(
                    successful,
                    len(to_unblacklist) - successful),
                parse_mode=ParseMode.HTML,
            )
    else:
        msg.reply_text("Dimmi quale parola vuoi rimuovere dalla blacklist.")
Beispiel #9
0
def unblacklist(bot: Bot, update: Update):
    msg = update.effective_message  # type: Optional[Message]
    chat = update.effective_chat  # type: Optional[Chat]
    words = msg.text.split(None, 1)
    if len(words) > 1:
        text = words[1]
        to_unblacklist = list(
            set(trigger.strip() for trigger in text.split("\n")
                if trigger.strip()))
        successful = 0
        for trigger in to_unblacklist:
            success = sql.rm_from_blacklist(chat.id, trigger.lower())
            if success:
                successful += 1

        if len(to_unblacklist) == 1:
            if successful:
                msg.reply_text(
                    "Removed <code>{}</code> from the blacklist!".format(
                        html.escape(to_unblacklist[0])),
                    parse_mode=ParseMode.HTML)
            else:
                msg.reply_text("This isn't a blacklisted trigger...!")

        elif successful == len(to_unblacklist):
            msg.reply_text(
                "Removed <code>{}</code> triggers from the blacklist.".format(
                    successful),
                parse_mode=ParseMode.HTML)

        elif not successful:
            msg.reply_text(
                "None of these triggers exist, so they weren't removed.".
                format(successful,
                       len(to_unblacklist) - successful),
                parse_mode=ParseMode.HTML)

        else:
            msg.reply_text(
                "Removed <code>{}</code> triggers from the blacklist. {} did not exist, "
                "so were not removed.".format(successful,
                                              len(to_unblacklist) -
                                              successful),
                parse_mode=ParseMode.HTML)
    else:
        msg.reply_text(
            "ആഹ്..നിങ്ങൾക്ക് ഏത് വാക്കാണ് black ലിസ്റ്റിൽ നിന്നും ഒഴിവാക്കേണ്ടത്."
        )
Beispiel #10
0
def unblacklist(bot: Bot, update: Update):
    msg = update.effective_message  # type: Optional[Message]
    chat = update.effective_chat  # type: Optional[Chat]
    words = msg.text.split(None, 1)
    if len(words) > 1:
        text = words[1]
        to_unblacklist = list(
            set(trigger.strip() for trigger in text.split("\n")
                if trigger.strip()))
        successful = 0
        for trigger in to_unblacklist:
            success = sql.rm_from_blacklist(chat.id, trigger.lower())
            if success:
                successful += 1

        if len(to_unblacklist) == 1:
            if successful:
                msg.reply_text(
                    "<code>{}</code> qara siyahıdan silindi!".format(
                        html.escape(to_unblacklist[0])),
                    parse_mode=ParseMode.HTML)
            else:
                msg.reply_text(
                    "Bu, qara siyahıya alınan bir tetikleyici deyil...!")

        elif successful == len(to_unblacklist):
            msg.reply_text(
                "<code>{}</code> tetik qara siyahıdan çıxarıldı.".format(
                    successful),
                parse_mode=ParseMode.HTML)

        elif not successful:
            msg.reply_text(
                "Bu tetiklərdən heç biri yoxdu, buna görədə silinmədi.".format(
                    successful,
                    len(to_unblacklist) - successful),
                parse_mode=ParseMode.HTML)

        else:
            msg.reply_text(
                "Qara siyahıdan <code>{}</code> tetikləyici silindi. {} silindi, "
                "buna görə qaldırılmadı.".format(
                    successful,
                    len(to_unblacklist) - successful),
                parse_mode=ParseMode.HTML)
    else:
        msg.reply_text(
            "Qara siyahıdan hansı sözləri çıxarmaq istədiyinizi söyləyin.")
def unblacklist(bot: Bot, update: Update):
    msg = update.effective_message
    chat = update.effective_chat
    words = msg.text.split(None, 1)

    if len(words) > 1:
        text = words[1]
        to_unblacklist = list(
            set(trigger.strip() for trigger in text.split("\n") if trigger.strip())
        )
        successful = 0

        for trigger in to_unblacklist:
            success = sql.rm_from_blacklist(chat.id, trigger.lower())
            if success:
                successful += 1

        if len(to_unblacklist) == 1:
            if successful:
                msg.reply_text(
                    f"Dihapus <code>{html.escape(to_unblacklist[0])}</code> dari daftar hitam!",
                    parse_mode=ParseMode.HTML,
                )
            else:
                msg.reply_text("Ini bukan pemicu yang masuk daftar hitam...!")

        elif successful == len(to_unblacklist):
            msg.reply_text(
                f"Dihapus <code>{successful}</code> pemicu dari daftar hitam.",
                parse_mode=ParseMode.HTML,
            )

        elif not successful:
            msg.reply_text(
                "Tidak satu pun dari pemicu ini ada, jadi tidak dihapus.",
                parse_mode=ParseMode.HTML,
            )

        else:
            msg.reply_text(
                f"Dihapus <code>{successful}</code> pemicu dari daftar hitam."
                f" {len(to_unblacklist) - successful} tidak ada, jadi tidak dihapus.",
                parse_mode=ParseMode.HTML,
            )
    else:
        msg.reply_text(
            "Beri tahu saya kata-kata yang ingin Anda hapus dari daftar hitam."
        )
Beispiel #12
0
def unblacklist(bot: Bot, update: Update):
    msg = update.effective_message  # type: Optional[Message]
    chat = update.effective_chat  # type: Optional[Chat]
    words = msg.text.split(None, 1)
    if len(words) > 1:
        text = words[1]
        to_unblacklist = list(
            set(trigger.strip() for trigger in text.split("\n")
                if trigger.strip()))
        successful = 0
        for trigger in to_unblacklist:
            success = sql.rm_from_blacklist(chat.id, trigger.lower())
            if success:
                successful += 1

        if len(to_unblacklist) == 1:
            if successful:
                msg.reply_text(
                    " <code>{}</code> yasaklı kelimelerden kaldırıldı!".format(
                        html.escape(to_unblacklist[0])),
                    parse_mode=ParseMode.HTML)
            else:
                msg.reply_text(
                    "Bu kara listeye alınmış bir tetikleyici değil....!")

        elif successful == len(to_unblacklist):
            msg.reply_text(
                " <code>{}</code> tetikleyici yasaklı kelimelerden kaldırıldı."
                .format(successful),
                parse_mode=ParseMode.HTML)

        elif not successful:
            msg.reply_text(
                "Bu tetikleyicilerin hiçbiri yok, bu yüzden kaldırılmadı..".
                format(successful,
                       len(to_unblacklist) - successful),
                parse_mode=ParseMode.HTML)

        else:
            msg.reply_text(
                " <code>{}</code> kara listeden tetikler. {} yoktu, "
                "bu yüzden kaldırılmadı.".format(
                    successful,
                    len(to_unblacklist) - successful),
                parse_mode=ParseMode.HTML)
    else:
        msg.reply_text(
            "Kara listeden hangi kelimeleri kaldırmak istediğinizi söyleyin.")
Beispiel #13
0
def unblacklist(bot: Bot, update: Update):
    msg = update.effective_message  # type: Optional[Message]
    chat = update.effective_chat  # type: Optional[Chat]
    words = msg.text.split(None, 1)
    if len(words) > 1:
        text = words[1]
        to_unblacklist = list(
            set(trigger.strip() for trigger in text.split("\n")
                if trigger.strip()))
        successful = 0
        for trigger in to_unblacklist:
            success = sql.rm_from_blacklist(chat.id, trigger.lower())
            if success:
                successful += 1

        if len(to_unblacklist) == 1:
            if successful:
                msg.reply_text(
                    "Qara Siyahıdan <code>{}</code> silindi!".format(
                        html.escape(to_unblacklist[0])),
                    parse_mode=ParseMode.HTML)
            else:
                msg.reply_text("Bu söz onsuzda Qara Siyahıda yoxdur...!")

        elif successful == len(to_unblacklist):
            msg.reply_text(
                "Qara Siyahıdan <code>{}</code> silindi.".format(successful),
                parse_mode=ParseMode.HTML)

        elif not successful:
            msg.reply_text(
                "verilənlərdən heç biri onsuzda Qara Siyahıda yoxdur, olmayan bir şeyi silə bilmərəm."
                .format(successful,
                        len(to_unblacklist) - successful),
                parse_mode=ParseMode.HTML)

        else:
            msg.reply_text(
                "Qara Siyahıdan <code>{}</code> silindi. {} mövcud deyil, "
                "ona görə də silinmədi.".format(
                    successful,
                    len(to_unblacklist) - successful),
                parse_mode=ParseMode.HTML)
    else:
        msg.reply_text(
            "Mənə Qara siyahıdan silmək istədiyin söz və ya sözlər verməlisən."
        )
Beispiel #14
0
def unblacklist(bot: Bot, update: Update):
    msg = update.effective_message  # type: Optional[Message]
    chat = update.effective_chat  # type: Optional[Chat]
    words = msg.text.split(None, 1)
    if len(words) > 1:
        text = words[1]
        to_unblacklist = list(
            set(trigger.strip() for trigger in text.split("\n")
                if trigger.strip()))
        successful = 0
        for trigger in to_unblacklist:
            success = sql.rm_from_blacklist(chat.id, trigger.lower())
            if success:
                successful += 1

        if len(to_unblacklist) == 1:
            if successful:
                msg.reply_text(
                    "हटा दिया <code>{}</code> ब्लैकलिस्ट से!".format(
                        html.escape(to_unblacklist[0])),
                    parse_mode=ParseMode.HTML)
            else:
                msg.reply_text("यह एक ब्लैक लिस्टेड ट्रिगर नहीं है ...!")

        elif successful == len(to_unblacklist):
            msg.reply_text(
                "हटा दिया <code>{}</code> ब्लैकलिस्ट से".format(successful),
                parse_mode=ParseMode.HTML)

        elif not successful:
            msg.reply_text(
                "इनमें से कोई भी ट्रिगर मौजूद नहीं है, इसलिए उन्हें हटाया नहीं गया था।"
                .format(successful,
                        len(to_unblacklist) - successful),
                parse_mode=ParseMode.HTML)

        else:
            msg.reply_text(
                "हटा दिया <code>{}</code> {} ब्लैकलिस्ट से मौजूद नहीं था, "
                "इसलिए हटाया नहीं गया.".format(
                    successful,
                    len(to_unblacklist) - successful),
                parse_mode=ParseMode.HTML)
    else:
        msg.reply_text(
            "मुझे बताओ कि आप किन शब्दों को ब्लैकलिस्ट से निकालना चाहेंगे।")
def unblacklist(bot: Bot, update: Update):
    msg = update.effective_message  # type: Optional[Message]
    chat = update.effective_chat  # type: Optional[Chat]
    words = msg.text.split(None, 1)
    if len(words) > 1:
        text = words[1]
        to_unblacklist = list(
            set(trigger.strip() for trigger in text.split("\n")
                if trigger.strip()))
        successful = 0
        for trigger in to_unblacklist:
            success = sql.rm_from_blacklist(chat.id, trigger.lower())
            if success:
                successful += 1

        if len(to_unblacklist) == 1:
            if successful:
                msg.reply_text(
                    "Usunięto <code>{}</code> z czarnej listy!".format(
                        html.escape(to_unblacklist[0])),
                    parse_mode=ParseMode.HTML)
            else:
                msg.reply_text("To nie jest zablokowane słowo...!")

        elif successful == len(to_unblacklist):
            msg.reply_text(
                "Usunięto <code>{}</code> z czarnej listy!".format(successful),
                parse_mode=ParseMode.HTML)

        elif not successful:
            msg.reply_text(
                "Żaden z wyzwalaczy nie istnieje, więc nie zostaną usunięte.".
                format(successful,
                       len(to_unblacklist) - successful),
                parse_mode=ParseMode.HTML)

        else:
            msg.reply_text(
                "Usunięto <code>{}</code> z czarnej listy. {} nie istnieje, "
                "więc nie zostanie usunięte.".format(
                    successful,
                    len(to_unblacklist) - successful),
                parse_mode=ParseMode.HTML)
    else:
        msg.reply_text(
            "Powiedz mi, które słowa chcesz usunąć z czarnej listy.")
Beispiel #16
0
def unblacklist(bot: Bot, update: Update):
    msg = update.effective_message  # type: Optional[Message]
    chat = update.effective_chat  # type: Optional[Chat]
    words = msg.text.split(None, 1)
    if len(words) > 1:
        text = words[1]
        to_unblacklist = list(
            set(trigger.strip() for trigger in text.split("\n")
                if trigger.strip()))
        successful = 0
        for trigger in to_unblacklist:
            success = sql.rm_from_blacklist(chat.id, trigger.lower())
            if success:
                successful += 1

        if len(to_unblacklist) == 1:
            if successful:
                msg.reply_text(
                    "وازيل <code>{}</code> من القائمة السوداء!".format(
                        html.escape(to_unblacklist[0])),
                    parse_mode=ParseMode.HTML)
            else:
                msg.reply_text("هذا ليس الزناد القائمة السوداء ...!")

        elif successful == len(to_unblacklist):
            msg.reply_text(
                "حذف <code>{}</code> مشغلات من القائمة السوداء.".format(
                    successful),
                parse_mode=ParseMode.HTML)

        elif not successful:
            msg.reply_text(
                "لا توجد أي من هذه المشغلات، لذلك لم تتم إزالتها.".format(
                    successful,
                    len(to_unblacklist) - successful),
                parse_mode=ParseMode.HTML)

        else:
            msg.reply_text(
                "ازيل <code>{}</code> مشغلات من القائمة السوداء. {} لم تكن موجودة، "
                "لذلك لم تتم إزالتها.".format(successful,
                                              len(to_unblacklist) -
                                              successful),
                parse_mode=ParseMode.HTML)
    else:
        msg.reply_text("أخبرني أي كلمات تريد إزالتها من القائمة السوداء.")
Beispiel #17
0
def unblacklist(bot: Bot, update: Update):
    msg = update.effective_message  # type: Optional[Message]
    chat = update.effective_chat  # type: Optional[Chat]
    words = msg.text.split(None, 1)
    if len(words) > 1:
        text = words[1]
        to_blacklist = text.split("\n")
        successful = 0
        for trigger in to_blacklist:
            success = sql.rm_from_blacklist(chat.id, trigger.lower())
            if success:
                successful += 1

        if len(to_blacklist) == 1:
            if successful:
                msg.reply_text(
                    "<code>{}</code> kelime karalistesinden kaldırıldı!".
                    format(html.escape(to_blacklist[0])),
                    parse_mode=ParseMode.HTML)
            else:
                msg.reply_text(
                    "Bu kara listeye alınmış bir tetikleyici değil...!")

        elif successful == len(to_blacklist):
            msg.reply_text(
                "<code>{}</code> tetikleyicisi karalisteden kaldırıldı.".
                format(successful),
                parse_mode=ParseMode.HTML)

        elif not successful:
            msg.reply_text(
                "Bu tetikleyicilerin hiçbiri mevcut değil, bu yüzden kaldırılmadılar."
                .format(successful,
                        len(to_blacklist) - successful),
                parse_mode=ParseMode.HTML)

        else:
            msg.reply_text(
                "<code>{}</code> tetikleyicisi karalisteden kaldırıldı. {} bulunamadı, "
                "bu yüzden kaldırılmadı.".format(
                    successful,
                    len(to_blacklist) - successful),
                parse_mode=ParseMode.HTML)
    else:
        msg.reply_text("Kara listeden çıkarmak istediğiniz kelimeleri söyle.")
Beispiel #18
0
def unblacklist(bot: Bot, update: Update):
    msg = update.effective_message  # type: Optional[Message]
    chat = update.effective_chat  # type: Optional[Chat]
    words = msg.text.split(None, 1)
    if len(words) > 1:
        text = words[1]
        to_unblacklist = list(
            set(trigger.strip() for trigger in text.split("\n")
                if trigger.strip()))
        successful = 0
        for trigger in to_unblacklist:
            success = sql.rm_from_blacklist(chat.id, trigger.lower())
            if success:
                successful += 1

        if len(to_unblacklist) == 1:
            if successful:
                msg.reply_text(
                    "کلمه/جمله <code>{}</code> از فیلترچی حذف شد!".format(
                        html.escape(to_unblacklist[0])),
                    parse_mode=ParseMode.HTML)
            else:
                msg.reply_text("این کلمه/جمله توی لیست فیلتر نیس!")

        elif successful == len(to_unblacklist):
            msg.reply_text(
                "کلمه/جمله <code>{}</code> از فیلترچی حذف شد!".format(
                    successful),
                parse_mode=ParseMode.HTML)

        elif not successful:
            msg.reply_text(
                "هیچکدوم ازین کلمات موجود نیستن ! پس حذف هم نمیشن".format(
                    successful,
                    len(to_unblacklist) - successful),
                parse_mode=ParseMode.HTML)

        else:
            msg.reply_text(
                "کلمه/جمله <code>{}</code> از فیلترچی حذف شد!. {} وجود نداره, "
                "بنابراین حذف نشدن .".format(successful,
                                             len(to_unblacklist) - successful),
                parse_mode=ParseMode.HTML)
    else:
        msg.reply_text("بهم بگو چه کلمات/جملاتی رو میخوای از فیلترچی حذف کنی🙄")
Beispiel #19
0
def unblacklist(bot: Bot, update: Update):
    msg = update.effective_message  # type: Optional[Message]
    chat = update.effective_chat  # type: Optional[Chat]
    words = msg.text.split(None, 1)
    if len(words) > 1:
        text = words[1]
        to_unblacklist = list(
            set(trigger.strip() for trigger in text.split("\n")
                if trigger.strip()))
        successful = 0
        for trigger in to_unblacklist:
            success = sql.rm_from_blacklist(chat.id, trigger.lower())
            if success:
                successful += 1

        if len(to_unblacklist) == 1:
            if successful:
                msg.reply_text("<code>{}</code> 가 Blacklist 에서 제거되었어요!".format(
                    html.escape(to_unblacklist[0])),
                               parse_mode=ParseMode.HTML)
            else:
                msg.reply_text("이 단어는 Blacklist 에 오른 메시지가 아니예요...!")

        elif successful == len(to_unblacklist):
            msg.reply_text(
                "<code>{}</code> 가 Blacklist 에서 제거되었어요.".format(successful),
                parse_mode=ParseMode.HTML)

        elif not successful:
            msg.reply_text(
                "이 메시지들은 모두 Blacklist 에 존재하지 않기 때문에 제거되지 않았어요.".format(
                    successful,
                    len(to_unblacklist) - successful),
                parse_mode=ParseMode.HTML)

        else:
            msg.reply_text(
                "<code>{}</code> 가 Blacklist 에서 제거되었어요. {} 라는 단어는 Blacklist 에 존재하지 않네요!"
                "그래서 삭제할 수 없어요.".format(successful,
                                        len(to_unblacklist) - successful),
                parse_mode=ParseMode.HTML)
    else:
        msg.reply_text("Blacklist 에서 어떤 단어를 삭제하고 싶으신지 말씀해주세요.")
Beispiel #20
0
def unblacklist(bot: Bot, update: Update):
    msg = update.effective_message  # type: Optional[Message]
    chat = update.effective_chat  # type: Optional[Chat]
    words = msg.text.split(None, 1)
    if len(words) > 1:
        text = words[1]
        to_unblacklist = list(set(trigger.strip() for trigger in text.split("\n") if trigger.strip()))
        successful = 0
        for trigger in to_unblacklist:
            success = sql.rm_from_blacklist(chat.id, trigger.lower())
            if success:
                successful += 1

        if len(to_unblacklist) == 1:
            if successful:
                msg.reply_text("Removed <code>{}</code> from the blacklist!".format(html.escape(to_unblacklist[0])),
                               parse_mode=ParseMode.HTML)
            else:
                msg.reply_text("මෙය අසාදු ලේඛණගත කළ ප්‍රේරකයක් නොවේ ...!")

        elif successful == len(to_unblacklist):
            msg.reply_text(
                "Removed <code>{}</code> triggers from the blacklist.".format(
                    successful), parse_mode=ParseMode.HTML)

        elif not successful:
            msg.reply_text(
                "මෙම ප්‍රේරක කිසිවක් නොපවතින බැවින් ඒවා ඉවත් නොකෙරුණි.".format(
                    successful, len(to_unblacklist) - successful), parse_mode=ParseMode.HTML)

        else:
            msg.reply_text(
                "Removed <code>{}</code> triggers from the blacklist. {} did not exist, "
                "එබැවින් ඉවත් නොකළේය.".format(successful, len(to_unblacklist) - successful),
                parse_mode=ParseMode.HTML)
    else:
        msg.reply_text("අසාදු ලේඛනයෙන් ඉවත් කිරීමට ඔබ කැමති වචන මොනවාදැයි මට කියන්න.")
def unblacklist(update, context):
    msg = update.effective_message
    chat = update.effective_chat
    user = update.effective_user
    words = msg.text.split(None, 1)

    conn = connected(context.bot, update, chat, user.id)
    if conn:
        chat_id = conn
        chat_name = dispatcher.bot.getChat(conn).title
    else:
        chat_id = update.effective_chat.id
        if chat.type == "private":
            return
        else:
            chat_name = chat.title
    chat_name = html.escape(chat_name)

    if len(words) > 1:
        text = words[1]
        to_unblacklist = list(
            set(trigger.strip() for trigger in text.split("\n") if trigger.strip())
        )
        successful = 0
        for trigger in to_unblacklist:
            success = sql.rm_from_blacklist(chat_id, trigger.lower())
            if success:
                successful += 1

        if len(to_unblacklist) == 1:
            if successful:
                send_message(
                    update.effective_message,
                    "Removed <code>{}</code> from blacklist in <b>{}</b>!".format(
                        html.escape(to_unblacklist[0]), chat_name
                    ),
                    parse_mode=ParseMode.HTML,
                )
            else:
                send_message(
                    update.effective_message, "This is not a blacklist trigger!"
                )

        elif successful == len(to_unblacklist):
            send_message(
                update.effective_message,
                "Removed <code>{}</code> from blacklist in <b>{}</b>!".format(
                    successful, chat_name
                ),
                parse_mode=ParseMode.HTML,
            )

        elif not successful:
            send_message(
                update.effective_message,
                "None of these triggers exist so it can't be removed.".format(
                    successful, len(to_unblacklist) - successful
                ),
                parse_mode=ParseMode.HTML,
            )

        else:
            send_message(
                update.effective_message,
                "Removed <code>{}</code> from blacklist. {} did not exist, "
                "so were not removed.".format(
                    successful, len(to_unblacklist) - successful
                ),
                parse_mode=ParseMode.HTML,
            )
    else:
        send_message(
            update.effective_message,
            "Tell me which words you would like to remove from blacklist!",
        )