我们的团队试图创建Telegram Bot,这对于使长消息中的电话号码可点击是至关重要的。有时我们必须向用户发送包含大量信息和少量电话号码的消息,因此很难获得电话,因为电报仅允许复制整个消息。如果我们发送没有任何减价的短消息,则电报移动应用将突出显示它:
await bot.send_message(chat_id, "Example text with a phone +79991234567")
Run Code Online (Sandbox Code Playgroud)
如果我们使用Markdown Telegram,还可以使数字可点击:
await bot.send_message(
chat_id,
"Example text with a phone [+79991234567](tel:+79991234567)",
parse_mode='Markdown'
)
Run Code Online (Sandbox Code Playgroud)
尽管如果消息是很长的电报,请忽略数字并不进行解析:
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'
)
Run Code Online (Sandbox Code Playgroud)
有没有一种方法可以使Telegram将电话号码显示为链接?谢谢
这不是重复的问题。我想在由C#编写的电报机器人中使用html代码。我搜索了SO,但没有找到任何答案。怎么做?我使用了TelegramBotSharp。这是与我所解释的部分有关的代码:
MessageTarget target = (MessageTarget)update.Chat ?? update.From;
if(Text.StartsWith("Hello")) {
bot.SendMessage(target, "Hello <a href='http://google.com'> dear</a>", true);
}
Run Code Online (Sandbox Code Playgroud)