How to add URL to InlineKeyboardButton for Telegram Bot

微笑、不失礼 提交于 2021-02-10 18:02:36

问题


I would like to make the button that will open URL (external hyperlink) in browser from Telegram chat. Currently, I developed only clickable action buttons.

update.message.reply_text(
    'Subscribe to us on Facebook and Telegram:',
    reply_markup=InlineKeyboardMarkup([
        [InlineKeyboardButton(text='on Facebook', callback_data='Facebook')],
        [InlineKeyboardButton(text='on Telegram', callback_data='Telegram')],
    ])
)

But how to make them as link (with arrow). I want to ask for users for sharing.


回答1:


Instead of callback_data argument you can use url and that's it.

update.message.reply_text(
    'Subscribe to us on Facebook and Telegram:',
    reply_markup=InlineKeyboardMarkup([
        [InlineKeyboardButton(text='on Facebook', url='https://facebook.com')],
        [InlineKeyboardButton(text='on Telegram', url='https://t.me')],
    ])
)


来源:https://stackoverflow.com/questions/62892272/how-to-add-url-to-inlinekeyboardbutton-for-telegram-bot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!