如何将 URL 添加到电报机器人的 InlineKeyboardButton [英] How to add URL to InlineKeyboardButton for Telegram Bot

查看:75
本文介绍了如何将 URL 添加到电报机器人的 InlineKeyboardButton的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想制作一个按钮,可以在浏览器中从 Telegram 聊天中打开 URL(外部超链接).目前,我只开发了可点击的操作按钮.

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.

推荐答案

您可以使用 url 而不是 callback_data 参数,就是这样.

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')],
    ])
)

这篇关于如何将 URL 添加到电报机器人的 InlineKeyboardButton的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆