Python: Telegram Methods
Send and edit messages, and build keyboards, from your Python bot.
Call any Telegram Bot API method on bot, using the same method names as Telegram's own documentation.
Sending messages
bot.sendMessage(u, 'Hello there!')
bot.sendPhoto(u, photo_url, caption='Nice view')
bot.sendDocument(u, file_url)
bot.editMessageText('Updated text', chat_id=u, message_id=msg_id)
bot.deleteMessage(u, msg_id)
bot.answerCallbackQuery(call.id, text='Done!')
Messages render as HTML by default — <b>, <i>, <code>, and <a href="..."> all work without any extra setup.
bot.sendMessage(u, '<b>Order #1042</b>\nStatus: <code>shipped</code>')
replyText shortcut
bot.replyText is a convenience wrapper for sending a message with an optional keyboard.
bot.replyText(u, 'Pick an option:', reply_markup=keyboard)
Keyboards
keyboard = InlineKeyboardMarkup()
keyboard.add(InlineKeyboardButton('Buy now', callback_data='buy'))
bot.sendMessage(u, 'Ready?', reply_markup=keyboard)
Web App buttons
Pass a plain URL string to web_app — no extra wrapping needed.
keyboard = InlineKeyboardMarkup()
keyboard.add(InlineKeyboardButton('Open App', web_app='https://example.com/app'))
Checking channel membership
try:
MembershipCheck('@mychannel', u)
except PermissionError:
bot.sendMessage(u, 'Please join @mychannel first.')
Last updated August 11, 2026