ios - 有没有办法从 Telegram 回调到另一个应用程序?
问题描述
我正在创建一个电报机器人,需要x 回调到另一个应用程序。
这是我打开 VLC 并流式传输视频的 x-callback。当我在 Siri Shortcuts 或 Safari 中使用它时效果很好。但我需要它来处理 Telegram 聊天对话。
vlc-x-callback://x-callback-url/stream?url=https://sample-videos.com/video123/mp4/720/big_buck_bunny_720p_1mb.mp4
当我将其作为原始文本发送时,它显然不会将其识别为有效的 url,并且什么也不做。我尝试将其格式化为Markdown、MarkdownV2 和HTML样式,但均无效。我也试过InlineKeyboardButton给它text
,url
但它抛出一个BadRequest
错误
telegram.error.BadRequest: Inline keyboard button url is invalid
从 Telegram 到另一个应用程序的 x-callback 是否有任何解决方法?
我的问题与实现无关,但这是我使用python-telegram-bot 的代码
from telegram import Update, ParseMode, InlineKeyboardButton, InlineKeyboardMarkup
from telegram.ext import CommandHandler, CallbackContext, Updater
my_x_callback = 'vlc-x-callback://x-callback-url/stream?url=https://sample-videos.com/video123/mp4/720/big_buck_bunny_720p_1mb.mp4'
def test(update: Update, context: CallbackContext):
update.message.reply_text(my_x_callback)
update.message.reply_text(f'[Play it on VLC]({my_x_callback})', parse_mode=ParseMode.MARKDOWN)
update.message.reply_text(f'[Play it on VLC]({my_x_callback})', parse_mode=ParseMode.MARKDOWN_V2)
update.message.reply_text(f'<a href="{my_x_callback}">Play it on VLC</a>', parse_mode=ParseMode.HTML)
button = InlineKeyboardButton('Play it on VLC', url=my_x_callback)
update.message.reply_text(
'Testing InlineKeyboard',
reply_markup=InlineKeyboardMarkup([[button]])
)
if __name__ == '__main__':
updater = Updater('TOKEN')
updater.dispatcher.add_handler(CommandHandler('test', test))
updater.start_polling()
updater.idle()
解决方案
I had a similar use case once where I wanted to use mailto:
links. My workaround is to create a website URL that points to the mailto:
link. I.e. flow is:
- Generate
mailto
link depending on users request - Generate
https://
url that points to the link - in my case that's done via a self-hosted YOURLS instance - used that generated URL either for an inline buttton or as text link.
推荐阅读
- javascript - Highcharts 远程数据 - JSON 对象未定义
- networking - 计算机网络-子网掩码
- javascript - setTimeout 并将按钮值复制到剪贴板
- java - 尝试为非注释类型创建代理
- ruby-on-rails - Capybara have_text 在它应该失败时通过
- ruby-on-rails - Send_data 更改语言问题 Rails
- xamarin - Mvvmcross Xamarin 表单导航页面样式不起作用
- r - 如何在 R 中保存为谷歌街景 API 的图像响应?
- android - 每秒读取和更新json文件数据
- excel - 跳过迭代列