當前位置: 首頁>>代碼示例>>Python>>正文


Python types.InlineKeyboardMarkup方法代碼示例

本文整理匯總了Python中telebot.types.InlineKeyboardMarkup方法的典型用法代碼示例。如果您正苦於以下問題:Python types.InlineKeyboardMarkup方法的具體用法?Python types.InlineKeyboardMarkup怎麽用?Python types.InlineKeyboardMarkup使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在telebot.types的用法示例。


在下文中一共展示了types.InlineKeyboardMarkup方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: gen_markup

# 需要導入模塊: from telebot import types [as 別名]
# 或者: from telebot.types import InlineKeyboardMarkup [as 別名]
def gen_markup():
    markup = InlineKeyboardMarkup()
    markup.row_width = 2
    markup.add(InlineKeyboardButton("Yes", callback_data="cb_yes"),
                               InlineKeyboardButton("No", callback_data="cb_no"))
    return markup 
開發者ID:eternnoir,項目名稱:pyTelegramBotAPI,代碼行數:8,代碼來源:inline_keyboard_example.py

示例2: send_list

# 需要導入模塊: from telebot import types [as 別名]
# 或者: from telebot.types import InlineKeyboardMarkup [as 別名]
def send_list(message):
    if message.chat.type == 'private' :
        un = message.from_user.username
        bot.send_chat_action(message.chat.id, 'typing')
        r = join.read_list(un)
        count = -1
        for count, line in enumerate(open("list", 'r')):
            pass
        count += 1
        rr = u'%s \n\n 目前共有%s人參與抽獎哦'%(r,count)
        bot.reply_to(message,rr)
    else:
        bot.send_chat_action(message.chat.id, 'typing')
        markup = types.InlineKeyboardMarkup()
        btn = types.InlineKeyboardButton('戳這裏!', url = 'https://t.me/yahahaabot')
        markup.add(btn)
        msg_id = bot.send_message(chat_id=message.chat.id, text=u'為了防止刷屏,請在私聊中使用此命令哦~',reply_markup=markup).message_id
        time.sleep(5)
        bot.delete_message(message.chat.id,msg_id) 
開發者ID:johnpoint,項目名稱:lottery_bot,代碼行數:21,代碼來源:main.py

示例3: bot_yyets

# 需要導入模塊: from telebot import types [as 別名]
# 或者: from telebot.types import InlineKeyboardMarkup [as 別名]
def bot_yyets(message):
    markup = types.InlineKeyboardMarkup()
    if message.text.count(' ') != 1:
        bot.send_chat_action(message.chat.id, 'typing')
        bot.send_message(message.chat.id, '輸入格式有誤,例:`/yyets 神盾局特工`', parse_mode='Markdown')
        return
    bot.send_chat_action(message.chat.id, 'typing')
    season_count, msg = yyets.get_season_count(message.text.split(' ')[1])
    if season_count == 0:
        bot.send_message(message.chat.id, msg)
        return
    elif season_count == 255:
        bot.send_message(message.chat.id, msg)
        return
    for button in range(1, season_count + 1):
        markup.add(types.InlineKeyboardButton
                   ("第%s季" % button,
                    callback_data='%s %s' % (message.text.split(' ')[1], button)))
    bot.send_message(message.chat.id, "你想看第幾季呢?請點擊選擇", reply_markup=markup) 
開發者ID:BennyThink,項目名稱:ExpressBot,代碼行數:21,代碼來源:main.py

示例4: create_server_markup

# 需要導入模塊: from telebot import types [as 別名]
# 或者: from telebot.types import InlineKeyboardMarkup [as 別名]
def create_server_markup(chat_id, op):
    """
    create server information markup based on different operation
    :param chat_id: chat_id from which conversation
    :param op: delete or stat
    :return: 2 lines in a row markup
    """
    one_latest_server = get_user_server(chat_id)  # type: List[Union[dict, Any]]  
    btn_list = []
    count = get_effective_count(chat_id)

    size = 2
    markup = types.InlineKeyboardMarkup(size)

    for index in range(0, count):
        btn_list.append(types.InlineKeyboardButton(
            "%s %s" % (one_latest_server[index]['hostname'], one_latest_server[index]['ip']),
            callback_data='%s %s' % (op, index)))

    for i in range(0, len(btn_list), size):
        part = btn_list[i:i + size]
        if len(part) == 3:
            markup.add(part[0], part[1], part[2])
        elif len(part) == 2:
            markup.add(part[0], part[1])
        else:
            markup.add(part[0])

    return markup 
開發者ID:BennyThink,項目名稱:ServerSan,代碼行數:31,代碼來源:main.py

示例5: set_buttons

# 需要導入模塊: from telebot import types [as 別名]
# 或者: from telebot.types import InlineKeyboardMarkup [as 別名]
def set_buttons():
    global button
    global button2
    button = types.InlineKeyboardMarkup()
    btn1 = types.InlineKeyboardButton(i18n.t('bot.btn1'), callback_data='/send')
    btn2 = types.InlineKeyboardButton(i18n.t('bot.btn2'), callback_data='/email')
    button.row(btn1, btn2)
    button2 = types.InlineKeyboardMarkup()
    btn3 = types.InlineKeyboardButton(i18n.t('bot.btn3'), callback_data='/as_is')
    btn4 = types.InlineKeyboardButton(i18n.t('bot.btn4'), callback_data='/converted')
    button2.row(btn3, btn4) 
開發者ID:GabrielRF,項目名稱:Send2KindleBot,代碼行數:13,代碼來源:pdftokindlebot.py

示例6: langkb

# 需要導入模塊: from telebot import types [as 別名]
# 或者: from telebot.types import InlineKeyboardMarkup [as 別名]
def langkb() :
    markup = types.InlineKeyboardMarkup()
    markup.row(types.InlineKeyboardButton(text='English',callback_data='chooselang:en'),types.InlineKeyboardButton(text='فارسی',callback_data='chooselang:fa'))
    return markup
# --- Multi Lang --- 
開發者ID:MagicNews,項目名稱:ASMagic,代碼行數:7,代碼來源:bot.py

示例7: gen_markup

# 需要導入模塊: from telebot import types [as 別名]
# 或者: from telebot.types import InlineKeyboardMarkup [as 別名]
def gen_markup(eventid):
    markup = InlineKeyboardMarkup()
    markup.row_width = zabbix_keyboard_row_width
    markup.add(
        InlineKeyboardButton(zabbix_keyboard_button_message,
                             callback_data='{}'.format(json.dumps(dict(action="messages", eventid=eventid)))),
        InlineKeyboardButton(zabbix_keyboard_button_acknowledge,
                             callback_data='{}'.format(json.dumps(dict(action="acknowledge", eventid=eventid)))),
        InlineKeyboardButton(zabbix_keyboard_button_history,
                             callback_data='{}'.format(json.dumps(dict(action="history", eventid=eventid)))),
        InlineKeyboardButton(zabbix_keyboard_button_history,
                             callback_data='{}'.format(json.dumps(dict(action="last value", eventid=eventid)))),
        InlineKeyboardButton(zabbix_keyboard_button_history,
                             callback_data='{}'.format(json.dumps(dict(action="graphs", eventid=eventid)))))
    return markup 
開發者ID:xxsokolov,項目名稱:Zabbix-Notification-Telegram,代碼行數:17,代碼來源:zbxTelegram.py

示例8: welcome

# 需要導入模塊: from telebot import types [as 別名]
# 或者: from telebot.types import InlineKeyboardMarkup [as 別名]
def welcome(m):
    cid = m.chat.id
    markup = types.InlineKeyboardMarkup()
    b = types.InlineKeyboardButton("Help",callback_data='help')
    c = types.InlineKeyboardButton("About",callback_data='amir')
    markup.add(b,c)
    nn = types.InlineKeyboardButton("Inline Mode", switch_inline_query='')
    oo = types.InlineKeyboardButton("Channel", url='https://telegram.me/offlineteam')
    markup.add(nn,oo)
    id = m.from_user.id
    redis.sadd('memberspy',id)
    bot.send_message(cid, "Hi \n\n Welcome To TweenRoBOT \n\n Please Choose One :)", disable_notification=True, reply_markup=markup)

################################################################################################################################################################################################# 
開發者ID:ThisIsAmir,項目名稱:TweenRoBot,代碼行數:16,代碼來源:bot.py

示例9: any_msg

# 需要導入模塊: from telebot import types [as 別名]
# 或者: from telebot.types import InlineKeyboardMarkup [as 別名]
def any_msg(message):
    banlist = redis.sismember('banlist', '{}'.format(m.from_user.id))
    if str(banlist) == 'False':
        keyboard = types.InlineKeyboardMarkup(row_width=2)
        url_button = types.InlineKeyboardButton(text="URL", url="https://ya.ru")
        callback_button = types.InlineKeyboardButton(text="Callback", callback_data="test")
        switch_button = types.InlineKeyboardButton(text="Switch", switch_inline_query="Telegram")
        keyboard.add(url_button, callback_button, switch_button)
        bot.send_message(message.chat.id, "Please Choose One :D", reply_markup=keyboard)

################################################################################################################################################################################################# 
開發者ID:ThisIsAmir,項目名稱:TweenRoBot,代碼行數:13,代碼來源:bot.py

示例10: stats

# 需要導入模塊: from telebot import types [as 別名]
# 或者: from telebot.types import InlineKeyboardMarkup [as 別名]
def stats(message):
    id = message.text.replace("/send ","")
    markup = types.InlineKeyboardMarkup()
    markup.add(types.InlineKeyboardButton('Sticker', callback_data='sticker'),types.InlineKeyboardButton('Document', callback_data='document'))
    markup.add(types.InlineKeyboardButton('Photo', callback_data='photo'),types.InlineKeyboardButton('Video', callback_data='video'))
    markup.add(types.InlineKeyboardButton('Audio', callback_data='Audio'))
    redis.hset('file_id',message.chat.id,'{}'.format(id))
    bot.send_message(message.chat.id, 'Select _One_ of these `Items.:D` \n\n (Note: GIFs are Documents)', reply_markup=markup,parse_mode="Markdown")
#################################################################################################################################################################################################



################################################################################################################################################################################################# 
開發者ID:ThisIsAmir,項目名稱:TweenRoBot,代碼行數:15,代碼來源:bot.py

示例11: test_InlineQueryResultCachedPhoto_with_markup

# 需要導入模塊: from telebot import types [as 別名]
# 或者: from telebot.types import InlineKeyboardMarkup [as 別名]
def test_InlineQueryResultCachedPhoto_with_markup():
    markup = types.InlineKeyboardMarkup()
    markup.add(types.InlineKeyboardButton("Google", url="http://www.google.com"))
    markup.add(types.InlineKeyboardButton("Yahoo", url="http://www.yahoo.com"))
    iq = types.InlineQueryResultCachedPhoto('aaa', 'Fileid', title='Title', reply_markup=markup)
    json_str = iq.to_json()
    assert 'aa' in json_str
    assert 'Fileid' in json_str
    assert 'Title' in json_str
    assert 'caption' not in json_str
    assert 'reply_markup' in json_str 
開發者ID:eternnoir,項目名稱:pyTelegramBotAPI,代碼行數:13,代碼來源:test_types.py

示例12: test_send_message_with_inlinemarkup

# 需要導入模塊: from telebot import types [as 別名]
# 或者: from telebot.types import InlineKeyboardMarkup [as 別名]
def test_send_message_with_inlinemarkup(self):
        text = 'CI Test Message'
        tb = telebot.TeleBot(TOKEN)
        markup = types.InlineKeyboardMarkup()
        markup.add(types.InlineKeyboardButton("Google", url="http://www.google.com"))
        markup.add(types.InlineKeyboardButton("Yahoo", url="http://www.yahoo.com"))
        ret_msg = tb.send_message(CHAT_ID, text, disable_notification=True, reply_markup=markup)
        assert ret_msg.message_id 
開發者ID:eternnoir,項目名稱:pyTelegramBotAPI,代碼行數:10,代碼來源:test_telebot.py

示例13: test_edit_markup

# 需要導入模塊: from telebot import types [as 別名]
# 或者: from telebot.types import InlineKeyboardMarkup [as 別名]
def test_edit_markup(self):
        text = 'CI Test Message'
        tb = telebot.TeleBot(TOKEN)
        markup = types.InlineKeyboardMarkup()
        markup.add(types.InlineKeyboardButton("Google", url="http://www.google.com"))
        markup.add(types.InlineKeyboardButton("Yahoo", url="http://www.yahoo.com"))
        ret_msg = tb.send_message(CHAT_ID, text, disable_notification=True, reply_markup=markup)
        markup.add(types.InlineKeyboardButton("Google2", url="http://www.google.com"))
        markup.add(types.InlineKeyboardButton("Yahoo2", url="http://www.yahoo.com"))
        new_msg = tb.edit_message_reply_markup(chat_id=CHAT_ID, message_id=ret_msg.message_id, reply_markup=markup)
        assert new_msg.message_id 
開發者ID:eternnoir,項目名稱:pyTelegramBotAPI,代碼行數:13,代碼來源:test_telebot.py

示例14: gen_markup

# 需要導入模塊: from telebot import types [as 別名]
# 或者: from telebot.types import InlineKeyboardMarkup [as 別名]
def gen_markup():
    markup = InlineKeyboardMarkup()
    markup.row_width = 2
    markup.add(
        InlineKeyboardButton("投稿", callback_data=f"post"),
        InlineKeyboardButton("私聊", callback_data=f"message"))
    return markup

    @bot.callback_query_handler(func=lambda call: True)
    def callback_query(call):
        if call_data == '投稿':
            pass 
開發者ID:Tooruchan,項目名稱:simple-forwarder-bot,代碼行數:14,代碼來源:bot.py

示例15: push_and_reply

# 需要導入模塊: from telebot import types [as 別名]
# 或者: from telebot.types import InlineKeyboardMarkup [as 別名]
def push_and_reply(msgid):
    global session_id
    session_id = str(msgid)
    markup = InlineKeyboardMarkup()
    markup.row_width = 2
    markup.add(
        InlineKeyboardButton("連接會話", callback_data=f"conn_session"),
        InlineKeyboardButton("退出會話", callback_data=f"change"),
        InlineKeyboardButton("拉黑", callback_data=f"addblock"))
    return markup 
開發者ID:Tooruchan,項目名稱:simple-forwarder-bot,代碼行數:12,代碼來源:bot.py


注:本文中的telebot.types.InlineKeyboardMarkup方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。