【问题标题】:How to send a hyperlink in bot.sendMessage()如何在 bot.sendMessage() 中发送超链接
【发布时间】:2017-12-29 07:38:05
【问题描述】:

我的机器人发送链接。所以我想包含一个超链接,就像你可以用 HTML 做的那样,例如-a href="google.com" Google /a 显示一个名为“Google”的可点击文本我如何在bot.sendMessage() 中做到这一点?如果您也有任何发送粗体消息的想法..

【问题讨论】:

标签: python telegram-bot telepot


【解决方案1】:

您可以使用formatting option 来执行此操作。

【讨论】:

    【解决方案2】:

    通过在 send_message() 中指定 pare_mode=ParseMode.HTML,您可以使用 HTML 标记。

    超链接示例

    bot.send_message(chat_id=update.message.chat_id, text="<a href='https://www.google.com/'>Google</a>",parse_mode=ParseMode.HTML)
    

    粗体示例

    bot.send_message(chat_id=update.message.chat_id, text="<b>Bold font</b>",parse_mode=ParseMode.HTML)
    

    更多格式选项请参考here

    【讨论】:

      猜你喜欢
      • 2014-07-11
      • 2020-04-06
      • 2021-08-13
      • 2016-07-22
      • 2016-12-15
      • 2020-11-20
      • 2013-05-31
      • 2018-10-18
      • 1970-01-01
      相关资源
      最近更新 更多