当前位置: 首页>>代码示例>>Python>>正文


Python Filters.text方法代码示例

本文整理汇总了Python中telegram.ext.Filters.text方法的典型用法代码示例。如果您正苦于以下问题:Python Filters.text方法的具体用法?Python Filters.text怎么用?Python Filters.text使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在telegram.ext.Filters的用法示例。


在下文中一共展示了Filters.text方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: polo

# 需要导入模块: from telegram.ext import Filters [as 别名]
# 或者: from telegram.ext.Filters import text [as 别名]
def polo(self, bot, update, user_data):
        msg = update.message.text.upper()
        conn = sqlite3.connect(self.mount_point + 'coders1.db')
        c = conn.cursor()
        c.execute("SELECT name FROM handles WHERE name=(?)", (msg,))
        if c.fetchone():
            keyboard = [[InlineKeyboardButton("Hackerearth", callback_data='HElist8'),
                         InlineKeyboardButton("Hackerrank", callback_data='HRlist8')],
                        [InlineKeyboardButton("Codechef", callback_data='CClist8'),
                         InlineKeyboardButton("Spoj", callback_data='SPlist8')],
                        [InlineKeyboardButton("Codeforces", callback_data='CFlist8'),
                         InlineKeyboardButton("ALL", callback_data='ALLlist8')]]
            reply_markup = InlineKeyboardMarkup(keyboard)
            update.message.reply_text('please select the judge or select all for showing all',
                                      reply_markup=reply_markup)
            user_data['name1'] = msg
            conn.close()
            return XOLO
        else:
            conn.close()
            update.message.reply_text("Sorry this name is not registered with me.")
            return ConversationHandler.END

    # FUNCTION TO SHOW THE KIND OF RANKLIST USER WANTS 
开发者ID:Gotham13121997,项目名称:superCodingBot,代码行数:26,代码来源:ranklist.py

示例2: blacklist

# 需要导入模块: from telegram.ext import Filters [as 别名]
# 或者: from telegram.ext.Filters import text [as 别名]
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 = BASE_BLACKLIST_STRING

    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("There are no blacklisted messages here!")
            return
        msg.reply_text(text, parse_mode=ParseMode.HTML) 
开发者ID:skittles9823,项目名称:SkittBot,代码行数:23,代码来源:blacklist.py

示例3: add_blacklist

# 需要导入模块: from telegram.ext import Filters [as 别名]
# 或者: from telegram.ext.Filters import text [as 别名]
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 add to the blacklist.") 
开发者ID:skittles9823,项目名称:SkittBot,代码行数:22,代码来源:blacklist.py

示例4: __init__

# 需要导入模块: from telegram.ext import Filters [as 别名]
# 或者: from telegram.ext.Filters import text [as 别名]
def __init__(self, api_key, fallback):
        self.compiler = HackerRankAPI(api_key=api_key)
        self.conv_handler = ConversationHandler(
            entry_points=[CommandHandler('compiler', self.compilers)],
            allow_reentry=True,
            states={
                LANG: [CallbackQueryHandler(self.lang, pass_user_data=True, pattern=r'\w*comp1\b')],
                CODE: [CallbackQueryHandler(self.code, pass_user_data=True, pattern=r'\w*so1\b')],
                DECODE: [MessageHandler(Filters.text, self.decode, pass_user_data=True)],
                TESTCASES: [MessageHandler(Filters.text, self.testcases, pass_user_data=True)],
                OTHER: [MessageHandler(Filters.text, self.other, pass_user_data=True)],
                FILE: [MessageHandler(Filters.document, self.filer, pass_user_data=True)],
                FILETEST: [MessageHandler(Filters.document, self.filetest, pass_user_data=True)]
            },
            fallbacks=[fallback]
        ) 
开发者ID:Gotham13121997,项目名称:superCodingBot,代码行数:18,代码来源:compiler.py

示例5: code

# 需要导入模块: from telegram.ext import Filters [as 别名]
# 或者: from telegram.ext.Filters import text [as 别名]
def code(bot, update, user_data):
        query = update.callback_query
        val = query.data
        val = str(val).replace("so1", "")
        if val == "code":
            bot.edit_message_text(
                text="selected",
                chat_id=query.message.chat_id, message_id=query.message.message_id)
            bot.send_message(chat_id=query.message.chat_id, text="please enter your code\n"
                                                                  "Please make sure that "
                                                                  "the first line is not a comment line",
                             reply_markup=ForceReply(True))
            return DECODE
        elif val == "file":
            bot.edit_message_text(text="please send your .txt file\nMaximum size 2mb", chat_id=query.message.chat_id,
                                  message_id=query.message.message_id)
            return FILE
        else:
            return ConversationHandler.END

    # FUNCTION TO GET TESTCASE FILE 
开发者ID:Gotham13121997,项目名称:superCodingBot,代码行数:23,代码来源:compiler.py

示例6: __init__

# 需要导入模块: from telegram.ext import Filters [as 别名]
# 或者: from telegram.ext.Filters import text [as 别名]
def __init__(self, mount_point, fallback):
        self.mount_point = mount_point
        self.utility = Utility(mount_point)
        self.conv_handler = ConversationHandler(
            entry_points=[CommandHandler('ranklist', self.ranklist)],
            allow_reentry=True,
            states={

                SELECTION: [CallbackQueryHandler(self.selection, pattern=r'\w*sel1\b')],
                HOLO: [CallbackQueryHandler(self.holo, pattern=r'\w*list6\b')],
                SOLO: [CallbackQueryHandler(self.solo, pattern=r'\w*list7\b')],
                POLO: [MessageHandler(Filters.text, self.polo, pass_user_data=True)],
                XOLO: [CallbackQueryHandler(self.xolo, pass_user_data=True, pattern=r'\w*list8\b')]
            },

            fallbacks=[fallback]
        ) 
开发者ID:Gotham13121997,项目名称:superCodingBot,代码行数:19,代码来源:ranklist.py

示例7: __init__

# 需要导入模块: from telegram.ext import Filters [as 别名]
# 或者: from telegram.ext.Filters import text [as 别名]
def __init__(self, mount_point, fallback):
        self.mount_point = mount_point
        self.conv_handler = ConversationHandler(
            entry_points=[CommandHandler('register', self.register)],
            allow_reentry=True,
            states={

                NAME: [MessageHandler(Filters.text, self.name, pass_user_data=True)],

                JUDGE: [CallbackQueryHandler(self.judge, pass_user_data=True, pattern=r'\w*reg1\b')],

                HANDLE: [MessageHandler(Filters.text, self.handle, pass_user_data=True)]
            },

            fallbacks=[fallback]
        ) 
开发者ID:Gotham13121997,项目名称:superCodingBot,代码行数:18,代码来源:register.py

示例8: __init__

# 需要导入模块: from telegram.ext import Filters [as 别名]
# 或者: from telegram.ext.Filters import text [as 别名]
def __init__(self, mount_point, admin_list, fallback):
        self.admin_list = admin_list
        self.mount_point = mount_point
        self.utility = Utility(mount_point)
        self.conv_handler1 = ConversationHandler(
            entry_points=[CommandHandler('broadcast', self.broadcast)],
            allow_reentry=True,
            states={
                BDC: [MessageHandler(Filters.text, self.broadcast_message)]
            },
            fallbacks=[fallback]
        )
        self.conv_handler2 = ConversationHandler(
            entry_points=[CommandHandler('senddb', self.getDb)],
            allow_reentry=True,
            states={
                DB: [MessageHandler(Filters.document, self.db)]
            },
            fallbacks=[fallback]
        )

    # START OF ADMIN CONVERSATION HANDLER TO BROADCAST MESSAGE 
开发者ID:Gotham13121997,项目名称:superCodingBot,代码行数:24,代码来源:admin.py

示例9: log_incoming_messages

# 需要导入模块: from telegram.ext import Filters [as 别名]
# 或者: from telegram.ext.Filters import text [as 别名]
def log_incoming_messages(_, update):
    """Log incoming messages to a log file and influxdb."""
    frontend_logger.debug('incoming messages: %s' % update)
    chat = update.message.chat
    target_chat = ''
    if chat.type == 'group':
        target_chat = chat.title
    elif chat.type == 'private':
        if chat.first_name:
            target_chat += chat.first_name
        if chat.last_name:
            target_chat += ' %s' % chat.last_name
        if chat.username:
            target_chat += ' (%s)' % chat.username
    message_logger.info('In: %s: %s' % (target_chat, update.message.text))
    fields = {'message': update.message.text}
    tags = {'chat': target_chat}
    log_to_influxdb.delay('messages', fields, tags) 
开发者ID:ekeih,项目名称:OmNomNom,代码行数:20,代码来源:frontend.py

示例10: __init__

# 需要导入模块: from telegram.ext import Filters [as 别名]
# 或者: from telegram.ext.Filters import text [as 别名]
def __init__(self):
        self.config_instance = self.config_init()
        updater = Updater(self.config_instance.TELEGRAM_BOT_KEY)
        dp = updater.dispatcher

        logging.basicConfig(
            format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
            filename=self.config_instance.LOG_FILE
        )

        dp.add_handler(MessageHandler(
            [Filters.text], self.command_check_resps))
        dp.add_handler(CommandHandler("start", self.command_start))
        dp.add_handler(CommandHandler(
            "roll", self.command_roll, pass_args=True))
        dp.add_handler(CommandHandler("leaderboard", self.command_leaderboard))
        dp.add_error_handler(self.error)

        jq = updater.job_queue
        jq.put(self.update_all_timers, 1)

        self.logger.info("Started... ")

        updater.start_polling()
        updater.idle() 
开发者ID:toymak3r,项目名称:CineMonster,代码行数:27,代码来源:Server.py

示例11: _group_hook

# 需要导入模块: from telegram.ext import Filters [as 别名]
# 或者: from telegram.ext.Filters import text [as 别名]
def _group_hook(self):
        # noinspection PyUnusedLocal
        def hook(update, context):
            msg = update.effective_message
            if msg.group_chat_created:
                self.bus.post(GroupChatCreatedEvent(chat_id=update.effective_chat.id,
                                                    message=self._plugin.parse_msg(msg).output,
                                                    user=self._plugin.parse_user(update.effective_user).output))
            elif msg.photo:
                self._msg_hook(PhotoMessageEvent)(update, context)
            elif msg.video:
                self._msg_hook(VideoMessageEvent)(update, context)
            elif msg.contact:
                self._msg_hook(ContactMessageEvent)(update, context)
            elif msg.location:
                self._msg_hook(LocationMessageEvent)(update, context)
            elif msg.document:
                self._msg_hook(DocumentMessageEvent)(update, context)
            elif msg.text:
                if msg.text.startswith('/'):
                    self._command_hook()(update, context)
                else:
                    self._msg_hook(TextMessageEvent)(update, context)

        return hook 
开发者ID:BlackLight,项目名称:platypush,代码行数:27,代码来源:telegram.py

示例12: _command_hook

# 需要导入模块: from telegram.ext import Filters [as 别名]
# 或者: from telegram.ext.Filters import text [as 别名]
def _command_hook(self):
        # noinspection PyUnusedLocal
        def hook(update, context):
            msg = update.effective_message
            m = re.match('\s*/([0-9a-zA-Z_-]+)\s*(.*)', msg.text)
            cmd = m.group(1).lower()
            args = [arg for arg in re.split('\s+', m.group(2)) if len(arg)]

            try:
                self._authorize(msg)
                self.bus.post(CommandMessageEvent(chat_id=update.effective_chat.id,
                                                  command=cmd,
                                                  cmdargs=args,
                                                  message=self._plugin.parse_msg(msg).output,
                                                  user=self._plugin.parse_user(update.effective_user).output))
            except PermissionError:
                pass

        return hook 
开发者ID:BlackLight,项目名称:platypush,代码行数:21,代码来源:telegram.py

示例13: run

# 需要导入模块: from telegram.ext import Filters [as 别名]
# 或者: from telegram.ext.Filters import text [as 别名]
def run(self):
        # noinspection PyPackageRequirements
        from telegram.ext import MessageHandler, Filters

        super().run()
        telegram = self._plugin.get_telegram()
        dispatcher = telegram.dispatcher

        dispatcher.add_handler(MessageHandler(Filters.group, self._group_hook()))
        dispatcher.add_handler(MessageHandler(Filters.text, self._msg_hook(TextMessageEvent)))
        dispatcher.add_handler(MessageHandler(Filters.photo, self._msg_hook(PhotoMessageEvent)))
        dispatcher.add_handler(MessageHandler(Filters.video, self._msg_hook(VideoMessageEvent)))
        dispatcher.add_handler(MessageHandler(Filters.contact, self._msg_hook(ContactMessageEvent)))
        dispatcher.add_handler(MessageHandler(Filters.location, self._msg_hook(LocationMessageEvent)))
        dispatcher.add_handler(MessageHandler(Filters.document, self._msg_hook(DocumentMessageEvent)))
        dispatcher.add_handler(MessageHandler(Filters.command, self._command_hook()))

        self.logger.info('Initialized Telegram backend')
        telegram.start_polling()


# vim:sw=4:ts=4:et: 
开发者ID:BlackLight,项目名称:platypush,代码行数:24,代码来源:telegram.py

示例14: cancel_cmd

# 需要导入模块: from telegram.ext import Filters [as 别名]
# 或者: from telegram.ext.Filters import text [as 别名]
def cancel_cmd(bot, update):
    user_id = update.effective_user.id
    message_id = update.effective_message.message_id
    callback_query_id = update.callback_query.id
    chat_id = update.effective_chat.id

    state_handler = StateHandler.get_instance()
    user = state_handler.get_user(user_id)

    if user.get_state() == UserState.COMMENTING:
        db = DBwrapper.get_instance()
        lang_id = db.get_lang_id(user_id)

        user.set_state(UserState.IDLE)
        bot.editMessageText(chat_id=chat_id, message_id=message_id, text=translate("cancelledMessage", lang_id))
        bot.answerCallbackQuery(callback_query_id=callback_query_id, text=translate("cancelledMessage", lang_id)) 
开发者ID:d-Rickyy-b,项目名称:Python-BlackJackBot,代码行数:18,代码来源:main.py

示例15: answer

# 需要导入模块: from telegram.ext import Filters [as 别名]
# 或者: from telegram.ext.Filters import text [as 别名]
def answer(bot, update):
    sender_id = update.message.from_user.id
    reply_to_message = update.message.reply_to_message
    text = str(update.message.text[8:])
    db = DBwrapper.get_instance()

    if reply_to_message is None:
        bot.sendMessage(sender_id, text="⚠ You need to reply to the user's comment!")
        return

    try:
        last_line = reply_to_message.text.split("\n")
        ll_list = last_line[-1].split(" | ")
        user_id = ll_list[0]
    except ValueError:
        return

    if not re.match("[0-9]+", user_id):
        bot.sendMessage(sender_id, "⚠ The user_id is not valid. Are you sure you replied to a user comment?")
        return

    answer_text = "{}\n\n{}".format(translate("answerFromDev", db.get_lang_id(user_id)), text)
    bot.sendMessage(chat_id=user_id, text=answer_text)
    bot.sendMessage(chat_id=sender_id, text="Message sent!") 
开发者ID:d-Rickyy-b,项目名称:Python-BlackJackBot,代码行数:26,代码来源:main.py


注:本文中的telegram.ext.Filters.text方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。