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


Python telegram.ReplyKeyboardMarkup方法代码示例

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


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

示例1: add_custom

# 需要导入模块: import telegram [as 别名]
# 或者: from telegram import ReplyKeyboardMarkup [as 别名]
def add_custom(bot, update, username):
    uid = util.uid_from_update(update)
    user = User.from_update(update)
    mid = util.mid_from_update(update)
    from components.basic import main_menu_buttons
    main_menu_markup = ReplyKeyboardMarkup(main_menu_buttons(uid in settings.MODERATORS))

    try:
        fav = Favorite.get(custom_bot=username)
        util.send_or_edit_md_message(
            bot, uid, mdformat.none_action(
                "{} is already a favorite of yours. /favorites".format(fav.custom_bot)),
            to_edit=mid,
            reply_markup=main_menu_markup)
    except Favorite.DoesNotExist:
        fav = Favorite(user=user, custom_bot=username, date_added=datetime.date.today())
        fav.save()
        msg = bot.formatter.send_or_edit(uid,
                                           mdformat.love("{} added to your /favorites.".format(fav.custom_bot)),
                                           to_edit=mid)
        mid = msg.message_id
        util.wait(bot, update)
        send_favorites_list(bot, update, to_edit=mid)
    return ConversationHandler.END 
开发者ID:JosXa,项目名称:BotListBot,代码行数:26,代码来源:favorites.py

示例2: send_next

# 需要导入模块: import telegram [as 别名]
# 或者: from telegram import ReplyKeyboardMarkup [as 别名]
def send_next(bot, update, job_queue: JobQueue, args=None):
    uid = util.uid_from_update(update)
    num_rows = None
    if args:
        try:
            num_rows = int(args[0])
        except:
            num_rows = None

    reply_markup = ReplyKeyboardMarkup(
        _crapPy_Tr0ll_kbmarkup(num_rows), one_time_keyboard=False, per_user=True
    )
    text = "ɹoʇɐɹǝuǝb ǝɯɐuɹǝsn ɯɐɹbǝןǝʇ"
    util.send_md_message(bot, uid, text, reply_markup=reply_markup)

    if util.is_group_message(update):
        del_msg = bot.formatter.send_message(
            update.effective_chat.id, "Have fun in private ;)\n/easteregg"
        )
        update.effective_message.delete()
        job_queue.run_once(
            lambda *_: del_msg.delete(safe=True), 4, name="delete easteregg hint"
        ) 
开发者ID:JosXa,项目名称:BotListBot,代码行数:25,代码来源:eastereggs.py

示例3: filer

# 需要导入模块: import telegram [as 别名]
# 或者: from telegram import ReplyKeyboardMarkup [as 别名]
def filer(bot, update, user_data):
        file_id = update.message.document.file_id
        if ComHandler.check_file_size(update):
            return ConversationHandler.END
        newFile = bot.get_file(file_id)
        newFile.download('abcd.txt')
        with open('abcd.txt', 'r') as f:
            source = f.read()
        user_data['code'] = source
        custom_keyboard = [['#no test case', '#send a .txt file']]
        reply_markup = ReplyKeyboardMarkup(custom_keyboard, one_time_keyboard=True, resize_keybord=True)
        update.message.reply_text(
            'Please send test cases together as you would do in online ide\nIf you dont want to provide test cases select #no test case\n I you want to send test cases as .txt file select #send a .txt file',
            reply_markup=reply_markup)
        # REMOVING THE FILE AFTER PROCESS IS COMPLETE
        os.remove('abcd.txt')
        return TESTCASES

    # FUNCTION TO GET THE SOURCE CODE SENT BY USER 
开发者ID:Gotham13121997,项目名称:superCodingBot,代码行数:21,代码来源:compiler.py

示例4: start

# 需要导入模块: import telegram [as 别名]
# 或者: from telegram import ReplyKeyboardMarkup [as 别名]
def start(bot, update):
    """
    Start function. Displayed whenever the /start command is called.
    This function sets the language of the bot.
    """
    # Create buttons to slect language:
    keyboard = [['ES', 'EN']]

    # Create initial message:
    message = "Hey, I'm DisAtBot! / ¡Hey, soy DisAtBot! \n\n\
Please select a language to start. / Por favor selecciona un idioma \
para comenzar."

    reply_markup = ReplyKeyboardMarkup(keyboard,
                                       one_time_keyboard=True,
                                       resize_keyboard=True)
    update.message.reply_text(message, reply_markup=reply_markup)

    return SET_LANG 
开发者ID:RodolfoFerro,项目名称:DisAtBot,代码行数:21,代码来源:DisAtBot.py

示例5: menu

# 需要导入模块: import telegram [as 别名]
# 或者: from telegram import ReplyKeyboardMarkup [as 别名]
def menu(bot, update):
    """
    Main menu function.
    This will display the options from the main menu.
    """
    # Create buttons to slect language:
    keyboard = [[send_report[LANG], view_map[LANG]],
                [view_faq[LANG], view_about[LANG]]]

    reply_markup = ReplyKeyboardMarkup(keyboard,
                                       one_time_keyboard=True,
                                       resize_keyboard=True)

    user = update.message.from_user
    logger.info("Menu command requested by {}.".format(user.first_name))
    update.message.reply_text(main_menu[LANG], reply_markup=reply_markup)

    return SET_STAT 
开发者ID:RodolfoFerro,项目名称:DisAtBot,代码行数:20,代码来源:DisAtBot.py

示例6: show_crawlers_to_search

# 需要导入模块: import telegram [as 别名]
# 或者: from telegram import ReplyKeyboardMarkup [as 别名]
def show_crawlers_to_search(self, bot, update, user_data):
        app = user_data.get('app')

        buttons = []

        def make_button(i, url):
            return '%d - %s' % (i + 1, urlparse(url).hostname)
        # end def
        for i in range(1, len(app.crawler_links) + 1, 2):
            buttons += [[
                make_button(i - 1, app.crawler_links[i - 1]),
                make_button(i, app.crawler_links[i]) if i < len(
                    app.crawler_links) else '',
            ]]
        # end for

        update.message.reply_text(
            'Choose where to search for your novel, \n'
            'or send /skip to search everywhere.',
            reply_markup=ReplyKeyboardMarkup(buttons, one_time_keyboard=True),
        )
        return 'handle_crawler_to_search'
    # end def 
开发者ID:dipu-bd,项目名称:lightnovel-crawler,代码行数:25,代码来源:telegram.py

示例7: show_source_selection

# 需要导入模块: import telegram [as 别名]
# 或者: from telegram import ReplyKeyboardMarkup [as 别名]
def show_source_selection(self, bot, update, user_data):
        app = user_data.get('app')
        selected = user_data.get('selected')

        if len(selected['novels']) == 1:
            app.init_crawler(selected['novels'][0]['url'])
            return self.get_novel_info(bot, update, user_data)
        # end if

        update.message.reply_text(
            ('Choose a source to download "%s", ' % selected['title']) +
            'or send /cancel to stop this session.',
            reply_markup=ReplyKeyboardMarkup([
                [
                    '%d. %s %s' % (
                        index + 1,
                        novel['url'],
                        novel['info'] if 'info' in novel else ''
                    )
                ] for index, novel in enumerate(selected['novels'])
            ], one_time_keyboard=True),
        )

        return 'handle_select_source'
    # end def 
开发者ID:dipu-bd,项目名称:lightnovel-crawler,代码行数:27,代码来源:telegram.py

示例8: range_selection_done

# 需要导入模块: import telegram [as 别名]
# 或者: from telegram import ReplyKeyboardMarkup [as 别名]
def range_selection_done(self, bot, update, user_data):
        app = user_data.get('app')
        update.message.reply_text(
            'You have selected %d chapters to download' % len(app.chapters)
        )
        if len(app.chapters) == 0:
            return self.display_range_selection_help(bot, update)
        # end if
        update.message.reply_text(
            'Do you want to generate a single file or split the books into volumes?',
            reply_markup=ReplyKeyboardMarkup([
                ['Single file', 'Split by volumes']
            ], one_time_keyboard=True),
        )
        return 'handle_pack_by_volume'
    # end def 
开发者ID:dipu-bd,项目名称:lightnovel-crawler,代码行数:18,代码来源:telegram.py

示例9: start

# 需要导入模块: import telegram [as 别名]
# 或者: from telegram import ReplyKeyboardMarkup [as 别名]
def start(bot, update):
    """
        Shows an welcome message and help info about the available commands.
    """
    me = bot.get_me()

    # Welcome message
    msg = _("Hello!\n")
    msg += _("I'm {0} and I came here to help you.\n").format(me.first_name)
    msg += _("What would you like to do?\n\n")
    msg += _("/support - Opens a new support ticket\n")
    msg += _("/settings - Settings of your account\n\n")

    # Commands menu
    main_menu_keyboard = [[telegram.KeyboardButton('/support')],
                          [telegram.KeyboardButton('/settings')]]
    reply_kb_markup = telegram.ReplyKeyboardMarkup(main_menu_keyboard,
                                                   resize_keyboard=True,
                                                   one_time_keyboard=True)

    # Send the message with menu
    bot.send_message(chat_id=update.message.chat_id,
                     text=msg,
                     reply_markup=reply_kb_markup) 
开发者ID:juliarizza,项目名称:helpdeskbot,代码行数:26,代码来源:main.py

示例10: settings

# 需要导入模块: import telegram [as 别名]
# 或者: from telegram import ReplyKeyboardMarkup [as 别名]
def settings(bot, update):
    """
        Configure the messages language using a custom keyboard.
    """
    # Languages message
    msg = _("Please, choose a language:\n")
    msg += "en_US - English (US)\n"
    msg += "pt_BR - Português (Brasil)\n"

    # Languages menu
    languages_keyboard = [
        [telegram.KeyboardButton('en_US - English (US)')],
        [telegram.KeyboardButton('pt_BR - Português (Brasil)')]
    ]
    reply_kb_markup = telegram.ReplyKeyboardMarkup(languages_keyboard,
                                                   resize_keyboard=True,
                                                   one_time_keyboard=True)

    # Sends message with languages menu
    bot.send_message(chat_id=update.message.chat_id,
                     text=msg,
                     reply_markup=reply_kb_markup) 
开发者ID:juliarizza,项目名称:helpdeskbot,代码行数:24,代码来源:main.py

示例11: language_command

# 需要导入模块: import telegram [as 别名]
# 或者: from telegram import ReplyKeyboardMarkup [as 别名]
def language_command(self, message, user_id, chat_id, user):
        """
        Handles the Language command and sends the lis of languages

        :param message: the message sent by the user
        :param user_id: User id
        :param chat_id: Chat id
        :param user: Dict with user configuration
        :return: None
        """
        languages = [[lang] for lang in sorted(self.get_languages().keys())]
        keyboard = ReplyKeyboardMarkup(languages, one_time_keyboard=True)
        text = self._get_template('language_answer.md').render()
        self.telegram_api.sendMessage(chat_id, text, reply_markup=keyboard)
        if self.get_group():
            user.set_field(chat_id, 'mode', 'setlanguage', group=self.get_group())
        else:
            user.set_field(user_id, 'mode', 'setlanguage', group=self.get_group()) 
开发者ID:Xevib,项目名称:osmbot,代码行数:20,代码来源:osmbot.py

示例12: settings_command

# 需要导入模块: import telegram [as 别名]
# 或者: from telegram import ReplyKeyboardMarkup [as 别名]
def settings_command(self, message, user_id, chat_id, u):
        """
        Answers the settings command

        :param message: User message
        :param user_id: User identifier
        :param chat_id: Chat id
        :param u: Uers object
        :param group: Boolen to indicate if it's on a group
        :return: None
        """

        if self.get_group():
            text = self._get_template('question_only_mention.md').render()
            k = ReplyKeyboardMarkup([['Language'], [text]], one_time_keyboard=True)
        else:
            k = ReplyKeyboardMarkup([['Language']], one_time_keyboard=True)
        text = self._get_template('configure_question.md').render()
        self.telegram_api.sendMessage(chat_id, text, reply_markup=k)
        if self.get_group():
            identifier = chat_id
        else:
            identifier = user_id
        u.set_field(identifier, 'mode', 'settings', group=self.get_group()) 
开发者ID:Xevib,项目名称:osmbot,代码行数:26,代码来源:osmbot.py

示例13: prompt_for_confirm

# 需要导入模块: import telegram [as 别名]
# 或者: from telegram import ReplyKeyboardMarkup [as 别名]
def prompt_for_confirm(bot, update: Update, user: User, render):
    reply_markup = ReplyKeyboardMarkup([['Resend confirmation email'], ['Change email']])
    update.message.reply_text(render('waiting_for_confirmation'), reply_markup=reply_markup) 
开发者ID:f213,项目名称:selfmailbot,代码行数:5,代码来源:app.py

示例14: section_keyboard

# 需要导入模块: import telegram [as 别名]
# 或者: from telegram import ReplyKeyboardMarkup [as 别名]
def section_keyboard(bot, update):
    """
    Command that shows keyboard of departments for:
    news, newson and newsoff
    """

    keys = [['Univaq'], ['Disim'], ['Mesva'],
            ['Discab'], ['Chiudi']]

    bot.sendMessage(update.message.chat_id,
                    'Scegli il dipartimento:',
                    reply_markup=telegram.ReplyKeyboardMarkup(
                        keys, one_time_keyboard=True))

    return "department" 
开发者ID:giacomocerquone,项目名称:UnivaqBot,代码行数:17,代码来源:news_commands.py

示例15: univaq

# 需要导入模块: import telegram [as 别名]
# 或者: from telegram import ReplyKeyboardMarkup [as 别名]
def univaq(bot, update):
    """
    Command that shows keyboard of sections for:
    inevidenza, ultimissime, univaqon, univaqoff
    """

    keys = [['In Evidenza'], ['Ultimissime'], ['Chiudi']]

    bot.sendMessage(update.message.chat_id,
                    'Scegli la sezione:',
                    reply_markup=telegram.ReplyKeyboardMarkup(
                        keys, one_time_keyboard=True))

    return "univaq" 
开发者ID:giacomocerquone,项目名称:UnivaqBot,代码行数:16,代码来源:univaq.py


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