def add_blacklist(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 = list(
            set(trigger.strip() for trigger in text.split("\n")
                if trigger.strip()))
        for trigger in to_blacklist:
            sql.add_to_blacklist(chat.id, trigger.lower())

        if len(to_blacklist) == 1:
            msg.reply_text(
                "Aggiunto <code>{}</code> alla blacklist!".format(
                    html.escape(to_blacklist[0])),
                parse_mode=ParseMode.HTML,
            )

        else:
            msg.reply_text(
                "Aggiunti <code>{}</code> triggers alla blacklist.".format(
                    len(to_blacklist)),
                parse_mode=ParseMode.HTML,
            )

    else:
        msg.reply_text("Dimmi quale parola vuoi aggiungere alla blacklist.")
Example #2
0
def add_blacklist(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 = list(
            set(trigger.strip() for trigger in text.split("\n")
                if trigger.strip()))
        for trigger in to_blacklist:
            sql.add_to_blacklist(chat.id, trigger.lower())

        if len(to_blacklist) == 1:
            msg.reply_text("Kara listeye <code>{}</code> eklendi!".format(
                html.escape(to_blacklist[0])),
                           parse_mode=ParseMode.HTML)

        else:
            msg.reply_text("Kara listeye <code>{}</code> eklendi.".format(
                len(to_blacklist)),
                           parse_mode=ParseMode.HTML)

    else:
        msg.reply_text(
            "Kara listeye hangi kelimeleri eklemek istediğini söyle.")
Example #3
0
def add_blacklist(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 = list(
            set(trigger.strip() for trigger in text.split("\n")
                if trigger.strip()))
        for trigger in to_blacklist:
            sql.add_to_blacklist(chat.id, trigger.lower())

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

        else:
            msg.reply_text(get_string(
                "blacklist", "MSG_BLACKLIST_ADD_SUCCESS_MULTIPLE",
                lang.get_lang(update.effective_chat.id)).format(
                    len(to_blacklist)),
                           parse_mode=ParseMode.HTML
                           )  # MSG_BLACKLIST_ADD_SUCCESS_MULTIPLE

    else:
        msg.reply_text(
            get_string("blacklist", "ERR_BAD_REQUEST",
                       lang.get_lang(
                           update.effective_chat.id)))  # ERR_BAD_REQUEST
Example #4
0
def add_blacklist(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_blacklist = list(set(trigger.strip() for trigger in text.split("\n") if trigger.strip()))
        for trigger in to_blacklist:
            sql.add_to_blacklist(chat_id, trigger.lower())

        if len(to_blacklist) == 1:
            msg.reply_text(tld(chat.id, "Added <code>{}</code> to the blacklist in <b>{}</b>!").format(html.escape(to_blacklist[0]), chat_name),
                           parse_mode=ParseMode.HTML)

        else:
            msg.reply_text(tld(chat.id, 
             "Added <code>{}</code> to the blacklist in <b>{}</b>!").format(len(to_blacklist)), chat_name, parse_mode=ParseMode.HTML)

    else:
        msg.reply_text(tld(chat.id, "Tell me which words you would like to add to the blacklist."))
Example #5
0
def add_blacklist(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 = list(
            set(trigger.strip() for trigger in text.split("\n")
                if trigger.strip()))
        for trigger in to_blacklist:
            sql.add_to_blacklist(chat.id, trigger.lower())

        if len(to_blacklist) == 1:
            msg.reply_text("एडेड <code>{}</code> तू ब्लैकलिस्ट!".format(
                html.escape(to_blacklist[0])),
                           parse_mode=ParseMode.HTML)

        else:
            msg.reply_text("एडेड <code>{}</code> ट्रिगर तू ब्लैकलिस्ट.".format(
                len(to_blacklist)),
                           parse_mode=ParseMode.HTML)

    else:
        msg.reply_text(
            "मुझे बताओ कि आप किन शब्दों को ब्लैकलिस्ट से निकालना चाहेंगे।")
Example #6
0
def add_blacklist(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 = list(
            set(trigger.strip() for trigger in text.split("\n")
                if trigger.strip()))
        for trigger in to_blacklist:
            sql.add_to_blacklist(chat.id, trigger.lower())

        if len(to_blacklist) == 1:
            msg.reply_text(
                " <code>{}</code> yasaklı kelimelere eklendi!".format(
                    html.escape(to_blacklist[0])),
                parse_mode=ParseMode.HTML)

        else:
            msg.reply_text(" <code>{}</code> kara listeye tetikler.".format(
                len(to_blacklist)),
                           parse_mode=ParseMode.HTML)

    else:
        msg.reply_text(
            "hangi kelimeyi yasaklı kelimelerden kaldırmak istiyorsun.")
Example #7
0
def add_blacklist(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 = list(
            set(trigger.strip() for trigger in text.split("\n")
                if trigger.strip()))
        for trigger in to_blacklist:
            sql.add_to_blacklist(chat.id, trigger.lower())

        if len(to_blacklist) == 1:
            msg.reply_text(
                "کلمه/جمله <code>{}</code> به فیلترچی اضافه شد".format(
                    html.escape(to_blacklist[0])),
                parse_mode=ParseMode.HTML)

        else:
            msg.reply_text(
                "کلمه/جمله <code>{}</code> به فیلترچی اضافه شد".format(
                    len(to_blacklist)),
                parse_mode=ParseMode.HTML)

    else:
        msg.reply_text(
            "بهم بگو چه کلمات یا جملاتی رو میخوای داخل  فیلترچی بزاری.")
Example #8
0
def add_blacklist(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_blacklist = list(
            set(trigger.strip() for trigger in text.split("\n") if trigger.strip())
        )

        for trigger in to_blacklist:
            sql.add_to_blacklist(chat.id, trigger.lower())

        if len(to_blacklist) == 1:
            msg.reply_text(
                f"Ditambahkan <code>{html.escape(to_blacklist[0])}</code> ke daftar hitam!",
                parse_mode=ParseMode.HTML,
            )

        else:
            msg.reply_text(
                f"Ditambahkan <code>{len(to_blacklist)}</code> pemicu ke daftar hitam.",
                parse_mode=ParseMode.HTML,
            )

    else:
        msg.reply_text(
            "Beri tahu saya kata-kata yang ingin Anda hapus dari daftar hitam."
        )
Example #9
0
def add_blacklist(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 = list(
            set(trigger.strip() for trigger in text.split("\n")
                if trigger.strip()))
        for trigger in to_blacklist:
            sql.add_to_blacklist(chat.id, trigger.lower())

        if len(to_blacklist) == 1:
            msg.reply_text("Added <code>{}</code> to the blacklist!".format(
                html.escape(to_blacklist[0])),
                           parse_mode=ParseMode.HTML)

        else:
            msg.reply_text(
                "Added <code>{}</code> triggers to the blacklist.".format(
                    len(to_blacklist)),
                parse_mode=ParseMode.HTML)

    else:
        msg.reply_text(
            "ആഹ്..നിങ്ങൾക്ക് ഏത് വാക്കാണ് black ലിസ്റ്റിൽ നിന്നും ഒഴിവാക്കേണ്ടത്?."
        )
Example #10
0
def add_blacklist(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 = list(
            set(trigger.strip() for trigger in text.split("\n")
                if trigger.strip()))
        for trigger in to_blacklist:
            sql.add_to_blacklist(chat.id, trigger.lower())

        if len(to_blacklist) == 1:
            msg.reply_text(
                "<code>{}</code> qara siyahıya əlavə olundu!".format(
                    html.escape(to_blacklist[0])),
                parse_mode=ParseMode.HTML)

        else:
            msg.reply_text("<code>{}</code> tetiklər əlavə olundu.".format(
                len(to_blacklist)),
                           parse_mode=ParseMode.HTML)

    else:
        msg.reply_text(
            "Qara siyahıdan hansı sözləri çıxarmaq istədiyinizi söyləyin.")
Example #11
0
def add_blacklist(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_blacklist = list(set(trigger.strip() for trigger in text.split("\n") if trigger.strip()))

        for trigger in to_blacklist:
            try:
                re.compile(trigger)
            except Exception as exce:
                msg.reply_text(f"Couldn't add regex, Error: {exce}")
                return
            check = infinite_loop_check(trigger)
            if not check:
               sql.add_to_blacklist(chat.id, trigger.lower())
            else:
                msg.reply_text("I'm afraid I can't add that regex.")
                return

        if len(to_blacklist) == 1:
            msg.reply_text(f"Added <code>{html.escape(to_blacklist[0])}</code> to the blacklist!",
                           parse_mode=ParseMode.HTML)

        else:
            msg.reply_text(f"Added <code>{len(to_blacklist)}</code> triggers to the blacklist.",
                           parse_mode=ParseMode.HTML)

    else:
        msg.reply_text("Tell me which words you would like to remove from the blacklist.")
Example #12
0
def add_blacklist(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 = list(
            set(trigger.strip() for trigger in text.split("\n")
                if trigger.strip()))
        for trigger in to_blacklist:
            sql.add_to_blacklist(chat.id, trigger.lower())

        if len(to_blacklist) == 1:
            msg.reply_text(
                "Qara Siyahıya <code>{}</code> əlavə edildi!".format(
                    html.escape(to_blacklist[0])),
                parse_mode=ParseMode.HTML)

        else:
            msg.reply_text(
                "Qara Siyahıya <code>{}</code> əlavə edildi.".format(
                    len(to_blacklist)),
                parse_mode=ParseMode.HTML)

    else:
        msg.reply_text("Mənə Qara Siyahıya əlavə ediləcək sözlər verməlisən.")
Example #13
0
def add_blacklist(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_blacklist = list(
            set(trigger.strip() for trigger in text.split("\n")
                if trigger.strip()))
        for trigger in to_blacklist:
            sql.add_to_blacklist(chat, trigger.lower())

        if len(to_blacklist) == 1:
            msg.reply_text(tld(
                chat.id, "Added <code>{}</code> to the blacklist!").format(
                    html.escape(to_blacklist[0])),
                           parse_mode='html')

        else:
            msg.reply_text(tld(
                chat.id,
                "Added <code>{}</code> triggers to the blacklist.").format(
                    len(to_blacklist)),
                           parse_mode='html')

    else:
        msg.reply_text(
            tld(chat.id,
                "Tell me which words you would like to add to the blacklist."))
Example #14
0
def add_blacklist(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 = list(
            set(trigger.strip() for trigger in text.split("\n")
                if trigger.strip()))
        for trigger in to_blacklist:
            sql.add_to_blacklist(chat.id, trigger.lower())

        if len(to_blacklist) == 1:
            msg.reply_text("اضيف <code>{}</code> الى القائمة السوداء!".format(
                html.escape(to_blacklist[0])),
                           parse_mode=ParseMode.HTML)

        else:
            msg.reply_text(
                "وأضاف <code>{}</code> المشغلات إلى القائمة السوداء.".format(
                    len(to_blacklist)),
                parse_mode=ParseMode.HTML)

    else:
        msg.reply_text("أخبرني أي كلمات تريد إزالتها من القائمة السوداء.")
Example #15
0
def add_blacklist(update: Update, context: CallbackContext):
    if not check_perms(update, 1):
        return
    bot = context.bot
    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]
        if "**" in text:
            msg.reply_text(
                "Can't set blacklist, please don't use consecutive multiple \"*\"."
            )
            return
        to_blacklist = list(
            set(trigger.strip() for trigger in text.split("\n")
                if trigger.strip()))
        for trigger in to_blacklist:
            sql.add_to_blacklist(chat.id, trigger.lower())

        if len(to_blacklist) == 1:
            msg.reply_text("Added <code>{}</code> to the blacklist!".format(
                html.escape(to_blacklist[0])),
                           parse_mode=ParseMode.HTML)

        else:
            msg.reply_text(
                "Added <code>{}</code> triggers to the blacklist.".format(
                    len(to_blacklist)),
                parse_mode=ParseMode.HTML)

    else:
        msg.reply_text(
            "Tell me which words you would like to add to the blacklist.")
Example #16
0
def add_blacklist(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 = list(
            set(trigger.strip() for trigger in text.split("\n")
                if trigger.strip()))
        for trigger in to_blacklist:
            sql.add_to_blacklist(chat.id, trigger.lower())

        if len(to_blacklist) == 1:
            msg.reply_text("Added <code>{}</code> to the blacklist!".format(
                html.escape(to_blacklist[0])),
                           parse_mode=ParseMode.HTML)

        else:
            msg.reply_text(
                "Added <code>{}</code> triggers to the blacklist.".format(
                    len(to_blacklist)),
                parse_mode=ParseMode.HTML)

    else:
        msg.reply_text(
            "Tell me which words you would like to remove from the blacklist.")
Example #17
0
def add_blacklist(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_blacklist = list(
            set(trigger.strip() for trigger in text.split("\n")
                if trigger.strip()))
        for trigger in to_blacklist:
            sql.add_to_blacklist(chat.id, trigger.lower())

        if len(to_blacklist) == 1:
            msg.reply_text("Added <code>{}</code> to the blacklist!".format(
                html.escape(to_blacklist[0])),
                           parse_mode=ParseMode.HTML)

        else:
            msg.reply_text(
                "Added <code>{}</code> triggers to the blacklist.".format(
                    len(to_blacklist)),
                parse_mode=ParseMode.HTML)

    else:
        msg.reply_text(
            "Tell me which words you would like to add to the blacklist.")
Example #18
0
def add_blacklist(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_blacklist = list(
            set(trigger.strip() for trigger in text.split("\n") if trigger.strip())
        )
        for trigger in to_blacklist:
            sql.add_to_blacklist(chat_id, trigger.lower())

        if len(to_blacklist) == 1:
            send_message(
                update.effective_message,
                "Added blacklist <code>{}</code> in chat: <b>{}</b>!".format(
                    html.escape(to_blacklist[0]), chat_name
                ),
                parse_mode=ParseMode.HTML,
            )

        else:
            send_message(
                update.effective_message,
                "Added blacklist trigger: <code>{}</code> in <b>{}</b>!".format(
                    len(to_blacklist), chat_name
                ),
                parse_mode=ParseMode.HTML,
            )

    else:
        send_message(
            update.effective_message,
            "Tell me which words you would like to add in blacklist.",
        )
Example #19
0
def add_blacklist(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 = list(set(trigger.strip() for trigger in text.split("\n") if trigger.strip()))
        for trigger in to_blacklist:
            sql.add_to_blacklist(chat.id, trigger.lower())

        if len(to_blacklist) == 1:
            msg.reply_text("Added <code>{}</code> to the blacklist!".format(html.escape(to_blacklist[0])),
                           parse_mode=ParseMode.HTML)

        else:
            msg.reply_text(
                "Added <code>{}</code> triggers to the blacklist.".format(len(to_blacklist)), parse_mode=ParseMode.HTML)

    else:
        msg.reply_text("අසාදු ලේඛනයෙන් ඉවත් කිරීමට ඔබ කැමති වචන මොනවාදැයි මට කියන්න.")
Example #20
0
def add_blacklist(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_blacklist = list(
            set(trigger.strip() for trigger in text.split("\n")
                if trigger.strip()))
        for trigger in to_blacklist:
            sql.add_to_blacklist(chat_id, trigger.lower())

        if len(to_blacklist) == 1:
            msg.reply_text(tld(chat.id, "blacklist_add").format(
                html.escape(to_blacklist[0]), chat_name),
                           parse_mode=ParseMode.HTML)

        else:
            msg.reply_text(tld(chat.id,
                               "blacklist_add").format(len(to_blacklist)),
                           chat_name,
                           parse_mode=ParseMode.HTML)

    else:
        msg.reply_text(tld(chat.id, "blacklist_err_add_no_args"))
Example #21
0
def add_blacklist(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 = list(
            set(trigger.strip() for trigger in text.split("\n")
                if trigger.strip()))
        for trigger in to_blacklist:
            sql.add_to_blacklist(chat.id, trigger.lower())

        if len(to_blacklist) == 1:
            msg.reply_text("<code>{}</code> 가 Blacklist 에 추가되었어요!".format(
                html.escape(to_blacklist[0])),
                           parse_mode=ParseMode.HTML)

        else:
            msg.reply_text("<code>{}</code> 가 Blacklist 에 추가되었어요!".format(
                len(to_blacklist)),
                           parse_mode=ParseMode.HTML)

    else:
        msg.reply_text("Blacklist 에 추가할 단어를 알려주세요.")
def add_blacklist(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 = list(
            set(trigger.strip() for trigger in text.split("\n")
                if trigger.strip()))
        for trigger in to_blacklist:
            sql.add_to_blacklist(chat.id, trigger.lower())

        if len(to_blacklist) == 1:
            msg.reply_text("Dodano <code>{}</code> na czarną listę!".format(
                html.escape(to_blacklist[0])),
                           parse_mode=ParseMode.HTML)

        else:
            msg.reply_text("Dodano <code>{}</code> na czarną listę!".format(
                len(to_blacklist)),
                           parse_mode=ParseMode.HTML)

    else:
        msg.reply_text("Jakie słowa chcesz usunąć z czarnej listy?")
Example #23
0
def __import_data__(chat_id, data):
    # set chat blacklist
    blacklist = data.get("blacklist", {})
    for trigger in blacklist:
        sql.add_to_blacklist(chat_id, trigger)