本文整理汇总了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
示例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)
示例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)
示例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
示例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)
示例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 ---
示例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
示例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)
#################################################################################################################################################################################################
示例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)
#################################################################################################################################################################################################
示例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")
#################################################################################################################################################################################################
#################################################################################################################################################################################################
示例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
示例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
示例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
示例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
示例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