本文整理汇总了Python中telebot.types.InlineKeyboardButton方法的典型用法代码示例。如果您正苦于以下问题:Python types.InlineKeyboardButton方法的具体用法?Python types.InlineKeyboardButton怎么用?Python types.InlineKeyboardButton使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类telebot.types
的用法示例。
在下文中一共展示了types.InlineKeyboardButton方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: gen_markup
# 需要导入模块: from telebot import types [as 别名]
# 或者: from telebot.types import InlineKeyboardButton [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 InlineKeyboardButton [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 InlineKeyboardButton [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: any_msg
# 需要导入模块: from telebot import types [as 别名]
# 或者: from telebot.types import InlineKeyboardButton [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)
#################################################################################################################################################################################################
示例5: create_server_markup
# 需要导入模块: from telebot import types [as 别名]
# 或者: from telebot.types import InlineKeyboardButton [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
示例6: set_buttons
# 需要导入模块: from telebot import types [as 别名]
# 或者: from telebot.types import InlineKeyboardButton [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)
示例7: langkb
# 需要导入模块: from telebot import types [as 别名]
# 或者: from telebot.types import InlineKeyboardButton [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 ---
示例8: welcome
# 需要导入模块: from telebot import types [as 别名]
# 或者: from telebot.types import InlineKeyboardButton [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: stats
# 需要导入模块: from telebot import types [as 别名]
# 或者: from telebot.types import InlineKeyboardButton [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")
#################################################################################################################################################################################################
#################################################################################################################################################################################################
示例10: test_InlineQueryResultCachedPhoto_with_markup
# 需要导入模块: from telebot import types [as 别名]
# 或者: from telebot.types import InlineKeyboardButton [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
示例11: test_send_message_with_inlinemarkup
# 需要导入模块: from telebot import types [as 别名]
# 或者: from telebot.types import InlineKeyboardButton [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
示例12: test_edit_markup
# 需要导入模块: from telebot import types [as 别名]
# 或者: from telebot.types import InlineKeyboardButton [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
示例13: default_markup
# 需要导入模块: from telebot import types [as 别名]
# 或者: from telebot.types import InlineKeyboardButton [as 别名]
def default_markup():
markup = types.InlineKeyboardMarkup(row_width=1)
markup.add(types.InlineKeyboardButton('Go to The Spaghetti Detective to take a closer look.',
url=site.build_full_url('/printers/')))
return markup
示例14: inline_markup
# 需要导入模块: from telebot import types [as 别名]
# 或者: from telebot.types import InlineKeyboardButton [as 别名]
def inline_markup(printer, buttons=['more_info']):
links = {
'cancel': { 'text': 'Yes it failed. Cancel the print!', 'url': site.build_full_url('/prints/{}/cancel/'.format(printer.current_print_id)) },
'resume': { 'text': 'It is a false alarm. Resume the print!', 'url': site.build_full_url('/prints/{}/resume/'.format(printer.current_print_id)) },
'do_not_ask': { 'text': 'Resume the print, and don\'t alert me for the rest of this print.', 'url': site.build_full_url('/prints/{}/resume/?mute_alert=true'.format(printer.current_print_id)) },
'more_info': { 'text': 'Go to The Spaghetti Detective to take a closer look.', 'url': site.build_full_url('/printers/') }
}
button_list = [
types.InlineKeyboardButton(links[button]['text'], url=links[button]['url']) for button in buttons
]
markup = types.InlineKeyboardMarkup(row_width=1)
markup.add(*button_list)
return markup
示例15: query_text
# 需要导入模块: from telebot import types [as 别名]
# 或者: from telebot.types import InlineKeyboardButton [as 别名]
def query_text(query):
user = query.from_user.username
name = query.from_user.first_name
lname = query.from_user.last_name
uid = query.from_user.id
markup = types.InlineKeyboardMarkup()
markup.add(types.InlineKeyboardButton('{}'.format(lname), url="https://telegram.me/{}".format(user)))
thumb_url = 'http://uupload.ir/files/7d23_download.png'
info = types.InlineQueryResultArticle('1',
'Your Info',
types.InputTextMessageContent('` Username` : @{}\nYour ` First Name` : *{}*\n` Your LastName` : *{}*\n` Your ID` : *{}*'.format(user,name,lname,uid), parse_mode="Markdown"),
reply_markup=markup,
thumb_url=thumb_url)
text = urllib.urlopen("http://vip.opload.ir/vipdl/94/11/amirhmz/joke.db").read()
text1 = text.split(",")
last = random.choice(text1)
joke = types.InlineQueryResultArticle('4', 'Joke', types.InputTextMessageContent('{}'.format(last)),thumb_url='http://uupload.ir/files/sfxc_download.jpg')
url = req.get('http://exchange.nalbandan.com/api.php?action=json')
data = url.json()
date = data['dollar']['date']
dollar = data['dollar']['persian']
dollar1 = data['dollar']['value']
dollar_rasmi = data['dollar_rasmi']['persian']
dollar_rasmi1 = data['dollar_rasmi']['value']
euro = data['euro']['persian']
euro1 = data['euro']['value']
gold_per_geram = data['gold_per_geram']['persian']
gold_per_geram1 = data['gold_per_geram']['value']
coin_new = data['coin_new']['persian']
coin_new1 = data['coin_new']['value']
pond = data['pond']['persian']
pond1 = data['pond']['value']
derham = data['coin_old']['persian']
derham1 = data['coin_old']['value']
coin_old = data['coin_old']['persian']
coin_old1 = data['coin_old']['value']
time_tmp = 'http://uupload.ir/files/66yl_download_(2).png'
dollar = types.InlineQueryResultArticle('3', 'Dollar', types.InputTextMessageContent("قیمت ارز رایج کشور در تاریخ : ``` {}``` \n به شرح زیر است : \n\n `{}` به قیمت *{}* تومن \n\n `{}` به قیمت *{}* تومن \n\n `{}` به قیمت *{}* تومن \n\n `{}` به قیمت *{}* تومن \n\n `{}` به قیمت *{}* تومن \n\n `{}` به قیمت *{}* تومن \n\n `{}` به قیمت *{}* تومن \n\n `{}` به قیمت *{}* تومن ".format(date,dollar,dollar1,dollar_rasmi,dollar_rasmi1,euro,euro1,gold_per_geram,gold_per_geram1,coin_new,coin_new1,pond,pond1,derham,derham1,coin_old,coin_old1), parse_mode='Markdown'), thumb_url=time_tmp)
url = req.get('http://api.gpmod.ir/time/')
data = url.json()
FAdate = data['FAdate']
FAtime = data['FAtime']
ENdate = data['ENdate']
ENtime = data['ENtime']
time_tmp = 'http://uupload.ir/files/zneb_download_(1).png'
timesend = types.InlineQueryResultArticle('2', 'Time', types.InputTextMessageContent('`{}` : *ساعت* `{}` \n\n `{}` *Time* : `{}`'.format(FAdate,FAtime,ENdate,ENtime), parse_mode='Markdown'), thumb_url=time_tmp)
bot.answer_inline_query(query.id, [info, dollar, joke, timesend], cache_time=5, switch_pm_text='Start bot')
#################################################################################################################################################################################################
# -*- coding: utf-8 -*-