[docs]class InlineKeyboard:
def __init__(self):
"""Create a new inline keyboard"""
self.keyboard = [[]]
[docs] def url(self, text, url):
"""Add a new url button to the keyboard.
Parameters
----------
text : str
The text of the button
url : str
The url of the button"""
self.keyboard[-1].append({"text": text, "url": url})
[docs] def url_new_row(self, text, url):
"""Add a new url button to the keyboard in a new row.
Parameters
----------
text : str
The text of the button
url : str
The url of the button"""
self.keyboard.append([])
self.keyboard[-1].append({"text": text, "url": url})
[docs] def callback(self, text, callback_data):
"""Add a new callback button to the keyboard.
Parameters
----------
text : str
The text of the button
callback_data : str
The callback data of the button"""
self.keyboard[-1].append({
"text": text,
"callback_data": callback_data
})
[docs] def callback_new_row(self, text, callback_data):
"""Add a new callback button to the keyboard in a new row.
Parameters
----------
text : str
The text of the button
callback_data : str
The callback data of the button"""
self.keyboard.append([])
self.keyboard[-1].append({
"text": text,
"callback_data": callback_data
})
[docs] def send(self):
"""Return the keyboard."""
return {"inline_keyboard": self.keyboard}