Python telepot.namedtuple.InlineKeyboardMarkup() Examples
The following are 13
code examples of telepot.namedtuple.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
telepot.namedtuple
, or try the search function
.
Example #1
Source File: quiz.py From telepot with MIT License | 6 votes |
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
Example #2
Source File: quiz.py From telepot with MIT License | 6 votes |
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
Example #3
Source File: quiza.py From telepot with MIT License | 6 votes |
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
Example #4
Source File: inline_keyboard.py From telepot with MIT License | 6 votes |
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)
Example #5
Source File: telegram.py From mcafee2cash with MIT License | 5 votes |
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)
Example #6
Source File: message.py From TeleTor with Apache License 2.0 | 5 votes |
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)
Example #7
Source File: message.py From TeleTor with Apache License 2.0 | 5 votes |
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])
Example #8
Source File: help.py From Siarobo with MIT License | 5 votes |
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]
Example #9
Source File: help.py From Siarobo with MIT License | 5 votes |
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)
Example #10
Source File: votea.py From telepot with MIT License | 5 votes |
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}))
Example #11
Source File: vote.py From telepot with MIT License | 5 votes |
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}))
Example #12
Source File: skeletona_route.py From telepot with MIT License | 5 votes |
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)
Example #13
Source File: skeleton_route.py From telepot with MIT License | 5 votes |
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)