Python telebot.types.InlineKeyboardMarkup() Examples
The following are 18
code examples of telebot.types.InlineKeyboardMarkup().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
telebot.types
, or try the search function
.
Example #1
Source File: inline_keyboard_example.py From pyTelegramBotAPI with GNU General Public License v2.0 | 11 votes |
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
Example #2
Source File: pdftokindlebot.py From Send2KindleBot with GNU General Public License v3.0 | 6 votes |
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)
Example #3
Source File: bot.py From ASMagic with GNU General Public License v3.0 | 6 votes |
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 ---
Example #4
Source File: main.py From lottery_bot with GNU General Public License v3.0 | 6 votes |
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)
Example #5
Source File: bot.py From TweenRoBot with MIT License | 5 votes |
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") ################################################################################################################################################################################################# #################################################################################################################################################################################################
Example #6
Source File: telegram_bot.py From TheSpaghettiDetective with GNU Affero General Public License v3.0 | 5 votes |
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
Example #7
Source File: bot.py From simple-forwarder-bot with MIT License | 5 votes |
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
Example #8
Source File: bot.py From simple-forwarder-bot with MIT License | 5 votes |
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
Example #9
Source File: test_telebot.py From pyTelegramBotAPI with GNU General Public License v2.0 | 5 votes |
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
Example #10
Source File: test_telebot.py From pyTelegramBotAPI with GNU General Public License v2.0 | 5 votes |
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
Example #11
Source File: test_types.py From pyTelegramBotAPI with GNU General Public License v2.0 | 5 votes |
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
Example #12
Source File: bot.py From TweenRoBot with MIT License | 5 votes |
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) #################################################################################################################################################################################################
Example #13
Source File: bot.py From TweenRoBot with MIT License | 5 votes |
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) #################################################################################################################################################################################################
Example #14
Source File: zbxTelegram.py From Zabbix-Notification-Telegram with MIT License | 5 votes |
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
Example #15
Source File: main.py From ServerSan with Apache License 2.0 | 4 votes |
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
Example #16
Source File: bot.py From TweenRoBot with MIT License | 4 votes |
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 -*-
Example #17
Source File: telegram_bot.py From TheSpaghettiDetective with GNU Affero General Public License v3.0 | 4 votes |
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
Example #18
Source File: main.py From ExpressBot with GNU General Public License v2.0 | 3 votes |
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)