如何使电话号码成为Telegram Bot中的链接? [英] How to make phone number a link in Telegram Bot?

查看:147
本文介绍了如何使电话号码成为Telegram Bot中的链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的团队试图创建Telegram Bot,这对于使可点击长消息中的电话号码至关重要.有时我们必须向用户发送包含大量信息和少量电话号码的消息,因此很难获得电话,因为电报仅允许复制整个消息. 如果我们发送没有任何减价的短信,则电报移动应用会突出显示该短信:

Our team tries to create the Telegram Bot and it is essential for us to make phone number in the long messages clickable. Sometimes we have to send our users messages with a lot of information and few phone numbers, so it is hard to get the phone, because telegram allows to copy only the whole message. If we send the short message without any markdown the telegram mobile app will highlight it:

await bot.send_message(chat_id, "Example text with a phone +79991234567")

如果我们使用Markdown电报,也请单击一个数字:

If we use Markdown Telegram also make a number be clickable:

await bot.send_message(
    chat_id,
    "Example text with a phone [+79991234567](tel:+79991234567)", 
    parse_mode='Markdown'
)

尽管消息是很长的电报,但请忽略数字并且不进行解析:

Although if the message is a quite long Telegram just ignore the numbers and don't parse:

await bot.send_message(
    chat_id, 
    "Example text with a phone [+79991234567](tel:+79991234567)\nwithin a long-long message\nwithin a long-long message\nwithin a long-long message\nwithin a long-long message\nwithin a long-long message\nwithin a long-long message\nwithin a long-long message\nwithin a long-long message\nwithin a long-long message\nwithin a long-long message", 
    parse_mode='Markdown'
)

有没有一种方法可以使Telegram将电话号码显示为链接?谢谢

Is there a way to make Telegram to show phone numbers as a link? Thank you

推荐答案

我发现,当字符串长度为200或更大时,突出显示将不起作用.似乎是非正式的限制.

I found that when string length is 200 or more, highlighting won't work. Seems like unofficial limitation.

这篇关于如何使电话号码成为Telegram Bot中的链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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