我正在使用电报Bot从python脚本发送信息。
我向电报机器人发送消息的功能是:
def telegram_bot_sendtext(bot_message):
bot_token = 'token'
bot_chatID = 'id'
send_text = 'https://api.telegram.org/bot' + bot_token + '/sendMessage?chat_id=' + bot_chatID + '&parse_mode=Markdown&text=' + bot_message
response = requests.get(send_text)
return response.json()
信息之一是一个名为“ URL”的变量,其中包含URL,例如,此变量:https://www.sezane.com/fr/product/collection-printemps-all-0804/robe-will?cou_Id=859
我有两个问题:
1]markdown
parseMode需要有效的markdown语法,我想您示例URL中的_
会启动一个永远不会关闭的Markdown italic text,Telegram返回错误并且消息将不会发送。用parse_mode: HTML
禁用此功能。 (html parsemode中没有parse_mode: HTML
元素)
2)_
和markDown
解析模式都提供了向消息添加超链接的选项;
HTML
HTML
MarkDown
<a href="https://www.google.com/">Google</a>
[Google](https://www.google.com/)
有关详细信息,请在telegram_bot_sendtext("Please press this [link](https://www.sezane.com/fr/product/collection-printemps-all-0804/robe-will?cou_Id=859)")
中查看。