コード例 #1
0
ファイル: cust_filters.py プロジェクト: timurmoore/timoore
def stop_all_filters(bot: Bot, update: Update):
    chat = update.effective_chat
    user = update.effective_user
    message = update.effective_message

    if chat.type == "private":
        chat.title = tld(chat.id, "cust_filters_local")
    else:
        owner = chat.get_member(user.id)
        chat.title = chat.title
        if owner.status != 'creator':
            message.reply_text(tld(chat.id, "notes_must_be_creator"))
            return

    x = 0
    flist = sql.get_chat_triggers(chat.id)

    if not flist:
        message.reply_text(
            tld(chat.id, "cust_filters_list_empty").format(chat.title))
        return

    f_flist = []
    for f in flist:
        x += 1
        f_flist.append(f)

    for fx in f_flist:
        sql.remove_filter(chat.id, fx)

    message.reply_text(tld(chat.id, "cust_filters_cleanup_success").format(x))
コード例 #2
0
ファイル: cust_filters.py プロジェクト: MhdRezza/hitsuki
def stop_all_filters(update, context):
    chat = update.effective_chat
    user = update.effective_user
    message = update.effective_message

    if chat.type == "private":
        chat.title = tl(chat.id, "local filters")
    else:
        owner = chat.get_member(user.id)
        chat.title = chat.title
        if owner.status != 'creator':
            message.reply_text(tl(chat.id, "You must be this chat creator."))
            return

    x = 0
    flist = sql.get_chat_triggers(chat.id)

    if not flist:
        message.reply_text(
            tl(chat.id,
               "There aren't any active filters in {}!").format(chat.title))
        return

    f_flist = []
    for f in flist:
        x += 1
        f_flist.append(f)

    for fx in f_flist:
        sql.remove_filter(chat.id, fx)

    message.reply_text(
        tl(chat.id, "{} filters from this chat have been removed.").format(x))
コード例 #3
0
def stop_filter(update, context):
    chat = update.effective_chat  # type: Optional[Chat]
    user = update.effective_user
    args = update.effective_message.text.split(None, 1)

    conn = connected(context.bot, update, chat, user.id)
    if conn is not False:
        chat_id = conn
        chat_name = dispatcher.bot.getChat(conn).title
    else:
        chat_id = update.effective_chat.id
        if chat.type == "private":
            chat_name = tl(update.effective_message, "catatan lokal")
        else:
            chat_name = chat.title

    if len(args) < 2:
        send_message(update.effective_message, tl(update.effective_message, "Apa yang harus saya hentikan?"))
        return

    chat_filters = sql.get_chat_triggers(chat_id)

    if not chat_filters:
        send_message(update.effective_message, tl(update.effective_message, "Tidak ada filter aktif di sini!"))
        return

    for keyword in chat_filters:
        if keyword == args[1].lower():
            sql.remove_filter(chat_id, args[1].lower())
            send_message(update.effective_message,
                         tl(update.effective_message, "Ya, saya akan berhenti menjawabnya di *{}*.").format(chat_name),
                         parse_mode=telegram.ParseMode.MARKDOWN)
            raise DispatcherHandlerStop

    send_message(update.effective_message, "Itu bukan filter aktif - jalankan /filter untuk semua filter aktif.")
コード例 #4
0
def stop_filter(bot: Bot, update: Update):
    chat = update.effective_chat  # type: Optional[Chat]
    user = update.effective_user  # type: Optional[User]
    args = update.effective_message.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":
            chat_name = "local notes"
        else:
            chat_name = chat.title

    if len(args) < 2:
        return

    chat_filters = sql.get_chat_triggers(chat_id)

    if not chat_filters:
        update.effective_message.reply_text(
            tld(chat.id, "No filters are active in {}!").format(chat_name))
        return

    for keyword in chat_filters:
        if keyword == args[1]:
            sql.remove_filter(chat_id, args[1])
            update.effective_message.reply_text(
                tld(chat.id,
                    "Yep, I'll stop replying to that in *{}*.").format(
                        chat_name),
                parse_mode=telegram.ParseMode.MARKDOWN)
            raise DispatcherHandlerStop

    update.effective_message.reply_text(
        tld(
            chat.id,
            "That's not an active filter - run /filters for all active filters."
        ))
コード例 #5
0
ファイル: cust_filters.py プロジェクト: timurmoore/timoore
def stop_filter(bot: Bot, update: Update):
    chat = update.effective_chat
    user = update.effective_user
    args = update.effective_message.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":
            chat_name = tld(chat.id, "cust_filters_local")
        else:
            chat_name = chat.title

    if len(args) < 2:
        return

    chat_filters = sql.get_chat_triggers(chat_id)

    if not chat_filters:
        update.effective_message.reply_text(
            tld(chat.id, "cust_filters_list_empty").format(chat_name))
        return

    for keyword in chat_filters:
        if keyword == args[1].lower():
            sql.remove_filter(chat_id, args[1].lower())
            update.effective_message.reply_text(
                tld(chat.id, "cust_filters_stop_success").format(chat_name),
                parse_mode=telegram.ParseMode.MARKDOWN)
            raise DispatcherHandlerStop

    update.effective_message.reply_text(
        tld(chat.id, "cust_filters_err_wrong_filter"))
コード例 #6
0
ファイル: cust_filters.py プロジェクト: Awesome-RJ/Hitsuki
        else:
            chat_name = chat.title

    if len(args) < 2:
        return

    chat_filters = sql.get_chat_triggers(chat_id)

    if not chat_filters:
        update.effective_message.reply_text(
            tld(chat.id, "cust_filters_list_empty").format(chat_name))
        return

    for keyword in chat_filters:
        if keyword == args[1].lower():
            sql.remove_filter(chat_id, args[1].lower())
            update.effective_message.reply_text(
                tld(chat.id, "cust_filters_stop_success").format(chat_name),
                parse_mode=telegram.ParseMode.MARKDOWN)
            raise DispatcherHandlerStop

    update.effective_message.reply_text(
        tld(chat.id, "cust_filters_err_wrong_filter"))


@run_async
def reply_filter(bot: Bot, update: Update):
    chat = update.effective_chat
    message = update.effective_message
    user = update.effective_user