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


Python namedtuple.InlineKeyboardMarkup方法代码示例

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


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

示例1: on_chat_message

# 需要导入模块: from telepot import namedtuple [as 别名]
# 或者: from telepot.namedtuple import InlineKeyboardMarkup [as 别名]
def on_chat_message(self, msg):
        content_type, chat_type, chat_id = telepot.glance(msg)
        self.sender.sendMessage(
            'Press START to do some math ...',
            reply_markup=InlineKeyboardMarkup(
                inline_keyboard=[[
                    InlineKeyboardButton(text='START', callback_data='start'),
                ]]
            )
        )
        self.close()  # let Quizzer take over 
开发者ID:nickoala,项目名称:telepot,代码行数:13,代码来源:quiz.py

示例2: _show_next_question

# 需要导入模块: from telepot import namedtuple [as 别名]
# 或者: from telepot.namedtuple import InlineKeyboardMarkup [as 别名]
def _show_next_question(self):
        x = random.randint(1,50)
        y = random.randint(1,50)
        sign, op = random.choice([('+', lambda a,b: a+b),
                                  ('-', lambda a,b: a-b),
                                  ('x', lambda a,b: a*b)])
        answer = op(x,y)
        question = '%d %s %d = ?' % (x, sign, y)
        choices = sorted(list(map(random.randint, [-49]*4, [2500]*4)) + [answer])

        self.editor.editMessageText(question,
            reply_markup=InlineKeyboardMarkup(
                inline_keyboard=[
                    list(map(lambda c: InlineKeyboardButton(text=str(c), callback_data=str(c)), choices))
                ]
            )
        )
        return answer 
开发者ID:nickoala,项目名称:telepot,代码行数:20,代码来源:quiz.py

示例3: on_chat_message

# 需要导入模块: from telepot import namedtuple [as 别名]
# 或者: from telepot.namedtuple import InlineKeyboardMarkup [as 别名]
def on_chat_message(self, msg):
        content_type, chat_type, chat_id = glance(msg)
        await self.sender.sendMessage(
            'Press START to do some math ...',
            reply_markup=InlineKeyboardMarkup(
                inline_keyboard=[[
                    InlineKeyboardButton(text='START', callback_data='start'),
                ]]
            )
        )
        self.close()  # let Quizzer take over 
开发者ID:nickoala,项目名称:telepot,代码行数:13,代码来源:quiza.py

示例4: on_chat_message

# 需要导入模块: from telepot import namedtuple [as 别名]
# 或者: from telepot.namedtuple import InlineKeyboardMarkup [as 别名]
def on_chat_message(msg):
    content_type, chat_type, chat_id = telepot.glance(msg)

    keyboard = InlineKeyboardMarkup(inline_keyboard=[
                   [InlineKeyboardButton(text='Press me', callback_data='press')],
               ])

    bot.sendMessage(chat_id, 'Use inline keyboard', reply_markup=keyboard) 
开发者ID:nickoala,项目名称:telepot,代码行数:10,代码来源:inline_keyboard.py

示例5: notify_tweet

# 需要导入模块: from telepot import namedtuple [as 别名]
# 或者: from telepot.namedtuple import InlineKeyboardMarkup [as 别名]
def notify_tweet(self, tweet_text, user, link, to_buy):
		buying_options = [InlineKeyboardButton(text=f'{x[1][0].upper()}{x[1][1:]} ({x[0]})', callback_data=f'summary_{x[0]}') for x in to_buy]
		keyboard = InlineKeyboardMarkup(inline_keyboard=[buying_options])
		message = f'{user}: {link}'
		self.bot.sendMessage(self.chat_id, message, reply_markup=keyboard) 
开发者ID:stephancill,项目名称:mcafee2cash,代码行数:7,代码来源:telegram.py

示例6: get_torrents_for_select

# 需要导入模块: from telepot import namedtuple [as 别名]
# 或者: from telepot.namedtuple import InlineKeyboardMarkup [as 别名]
def get_torrents_for_select(self, action='stop') -> KeyboardMarkup:
        """
        Returns keyboard markup with torrents
        :param action:
        :return:
        """
        torrents_list = self.get_torrents()
        keyboard_ids = list([
            list([
                InlineKeyboardButton(text=torrent['name'], callback_data=f"{action}_{torrent['id']}")
            ]) for torrent in torrents_list
        ])

        return InlineKeyboardMarkup(inline_keyboard=keyboard_ids) 
开发者ID:iRay,项目名称:TeleTor,代码行数:16,代码来源:message.py

示例7: select_download_dir

# 需要导入模块: from telepot import namedtuple [as 别名]
# 或者: from telepot.namedtuple import InlineKeyboardMarkup [as 别名]
def select_download_dir():
        favourites_buttons = [InlineKeyboardButton(text=f_alias, callback_data=f"favourite_{f_alias}")
                              for f_alias in favourites]
        return InlineKeyboardMarkup(inline_keyboard=[favourites_buttons]) 
开发者ID:iRay,项目名称:TeleTor,代码行数:6,代码来源:message.py

示例8: run

# 需要导入模块: from telepot import namedtuple [as 别名]
# 或者: from telepot.namedtuple import InlineKeyboardMarkup [as 别名]
def run(message, matches, chat_id, step):
    response = Message(chat_id)
    res = show_help(0)
    if public_plugins:
        res.append([InlineKeyboardButton(text='Next ▶️', callback_data='/helpn 1')])
    markup = InlineKeyboardMarkup(inline_keyboard=res)
    response.set_text("Welcome to Siarobo\nSelect One of these Items.", parse_mode="Markdown", reply_markup=markup)
    return [response] 
开发者ID:siyanew,项目名称:Siarobo,代码行数:10,代码来源:help.py

示例9: callback

# 需要导入模块: from telepot import namedtuple [as 别名]
# 或者: from telepot.namedtuple import InlineKeyboardMarkup [as 别名]
def callback(message, matches, chat_id):
    query_id, from_id, data = telepot.glance(message, flavor='callback_query')
    if data == "/help":
        res = show_help(0)
        if len(public_plugins) > 10:
            res.append([InlineKeyboardButton(text='Next ▶️', callback_data='/helpn 1')])
        markup = InlineKeyboardMarkup(inline_keyboard=res)
        msgid = (chat_id, message['message']['message_id'])
        return Message(from_id).edit_message(msgid, "Welcome to Siarobo\nSelect One of these Items.",
                                             parse_mode="Markdown",
                                             reply_markup=markup)
    elif "/helpn" in data:
        num = int(matches)
        res = show_help(num)
        if len(public_plugins) > (num + 1) * 10 and num != 0:
            res.append([InlineKeyboardButton(text='◀️ Previous', callback_data='/helpn ' + str(num - 1)),
                        InlineKeyboardButton(text='Next ▶️', callback_data='/helpn ' + str(num + 1))])
        elif len(public_plugins) > (num + 1) * 10:
            res.append([InlineKeyboardButton(text='Next ▶️', callback_data='/helpn ' + str(num + 1))])
        elif num != 0:
            res.append([InlineKeyboardButton(text='◀️ Previous', callback_data='/helpn ' + str(num - 1))])
        markup = InlineKeyboardMarkup(inline_keyboard=res)
        msgid = (chat_id, message['message']['message_id'])
        return Message(from_id).edit_message(msgid, "Welcome to Siarobo\nSelect One of these Items.",
                                             parse_mode="Markdown",
                                             reply_markup=markup)
    elif matches:
        tokenize = matches.split("--")
        matches = tokenize[0]
        markup = InlineKeyboardMarkup(
            inline_keyboard=[[InlineKeyboardButton(text='Return', callback_data='/helpn ' + tokenize[1])]])
        msgid = (chat_id, message['message']['message_id'])
        return Message(from_id).edit_message(msgid, show_shelp(matches), parse_mode="Markdown", reply_markup=markup) 
开发者ID:siyanew,项目名称:Siarobo,代码行数:35,代码来源:help.py

示例10: _init_ballot

# 需要导入模块: from telepot import namedtuple [as 别名]
# 或者: from telepot.namedtuple import InlineKeyboardMarkup [as 别名]
def _init_ballot(self):
        keyboard = InlineKeyboardMarkup(inline_keyboard=[[
                       InlineKeyboardButton(text='Yes', callback_data='yes'),
                       InlineKeyboardButton(text='Nah!!!!', callback_data='no'),
                   ]])
        sent = await self.sender.sendMessage("Let's Vote ...", reply_markup=keyboard)

        self._member_count = await self.administrator.getChatMembersCount() - 1  # exclude myself, the bot

        self._ballot_box = {}
        self._keyboard_msg_ident = message_identifier(sent)
        self._editor = telepot.aio.helper.Editor(self.bot, self._keyboard_msg_ident)

        # Generate an expiry event 30 seconds later
        self._expired_event = self.scheduler.event_later(30, ('_vote_expired', {'seconds': 30})) 
开发者ID:nickoala,项目名称:telepot,代码行数:17,代码来源:votea.py

示例11: _init_ballot

# 需要导入模块: from telepot import namedtuple [as 别名]
# 或者: from telepot.namedtuple import InlineKeyboardMarkup [as 别名]
def _init_ballot(self):
        keyboard = InlineKeyboardMarkup(inline_keyboard=[[
                       InlineKeyboardButton(text='Yes', callback_data='yes'),
                       InlineKeyboardButton(text='Nah!!!!', callback_data='no'),
                   ]])
        sent = self.sender.sendMessage("Let's Vote ...", reply_markup=keyboard)

        self._ballot_box = {}
        self._keyboard_msg_ident = telepot.message_identifier(sent)
        self._editor = telepot.helper.Editor(self.bot, self._keyboard_msg_ident)

        # Generate an expiry event 30 seconds later
        self._expired_event = self.scheduler.event_later(30, ('_vote_expired', {'seconds': 30})) 
开发者ID:nickoala,项目名称:telepot,代码行数:15,代码来源:vote.py

示例12: on_chat_message

# 需要导入模块: from telepot import namedtuple [as 别名]
# 或者: from telepot.namedtuple import InlineKeyboardMarkup [as 别名]
def on_chat_message(msg):
    content_type, chat_type, chat_id = telepot.glance(msg)
    print('Chat:', content_type, chat_type, chat_id)

    if content_type != 'text':
        return

    command = msg['text'][-1:].lower()

    if command == 'c':
        markup = ReplyKeyboardMarkup(keyboard=[
                     ['Plain text', KeyboardButton(text='Text only')],
                     [dict(text='Phone', request_contact=True), KeyboardButton(text='Location', request_location=True)],
                 ])
        await bot.sendMessage(chat_id, 'Custom keyboard with various buttons', reply_markup=markup)
    elif command == 'i':
        markup = InlineKeyboardMarkup(inline_keyboard=[
                     [dict(text='Telegram URL', url='https://core.telegram.org/')],
                     [InlineKeyboardButton(text='Callback - show notification', callback_data='notification')],
                     [dict(text='Callback - show alert', callback_data='alert')],
                     [InlineKeyboardButton(text='Callback - edit message', callback_data='edit')],
                     [dict(text='Switch to using bot inline', switch_inline_query='initial query')],
                 ])

        global message_with_inline_keyboard
        message_with_inline_keyboard = await bot.sendMessage(chat_id, 'Inline keyboard with various buttons', reply_markup=markup)
    elif command == 'h':
        markup = ReplyKeyboardRemove()
        await bot.sendMessage(chat_id, 'Hide custom keyboard', reply_markup=markup)
    elif command == 'f':
        markup = ForceReply()
        await bot.sendMessage(chat_id, 'Force reply', reply_markup=markup) 
开发者ID:nickoala,项目名称:telepot,代码行数:34,代码来源:skeletona_route.py

示例13: on_chat_message

# 需要导入模块: from telepot import namedtuple [as 别名]
# 或者: from telepot.namedtuple import InlineKeyboardMarkup [as 别名]
def on_chat_message(msg):
    content_type, chat_type, chat_id = telepot.glance(msg)
    print('Chat:', content_type, chat_type, chat_id)

    if content_type != 'text':
        return

    command = msg['text'][-1:].lower()

    if command == 'c':
        markup = ReplyKeyboardMarkup(keyboard=[
                     ['Plain text', KeyboardButton(text='Text only')],
                     [dict(text='Phone', request_contact=True), KeyboardButton(text='Location', request_location=True)],
                 ])
        bot.sendMessage(chat_id, 'Custom keyboard with various buttons', reply_markup=markup)
    elif command == 'i':
        markup = InlineKeyboardMarkup(inline_keyboard=[
                     [dict(text='Telegram URL', url='https://core.telegram.org/')],
                     [InlineKeyboardButton(text='Callback - show notification', callback_data='notification')],
                     [dict(text='Callback - show alert', callback_data='alert')],
                     [InlineKeyboardButton(text='Callback - edit message', callback_data='edit')],
                     [dict(text='Switch to using bot inline', switch_inline_query='initial query')],
                 ])

        global message_with_inline_keyboard
        message_with_inline_keyboard = bot.sendMessage(chat_id, 'Inline keyboard with various buttons', reply_markup=markup)
    elif command == 'h':
        markup = ReplyKeyboardRemove()
        bot.sendMessage(chat_id, 'Hide custom keyboard', reply_markup=markup)
    elif command == 'f':
        markup = ForceReply()
        bot.sendMessage(chat_id, 'Force reply', reply_markup=markup) 
开发者ID:nickoala,项目名称:telepot,代码行数:34,代码来源:skeleton_route.py


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