【发布时间】:2020-09-22 23:49:35
【问题描述】:
我们可以格式化彩色短信并发送FormattedMessage吗?
使用 JavaScript + Google Web Apps 与 Telegram Bot 交互。
function sendFormattedMessage( chat_id, text, parse_mode, disable_web_page_preview, disable_notification ) {
var encodedText = encodeURIComponent(text);
var response = UrlFetchApp.fetch(vUrlTelegram + "/sendMessage?chat_id=" + chat_id + "&text=" + encodedText + "&parse_mode=" + parse_mode );
// Logger.log(response.getContentText());
}
function telegramBotMachine( id, chat_id, text, name ) {
var sUpperText = text.toUpperCase();
if ( sUpperText.substr( 0, 4 ) === "MENU" ) {
sendFormattedMessage( chat_id, menu(), "HTML", "false", "false" );
已获得 Telegram Bot API 文档,无法找到 HTML 标签来对文本进行颜色格式化?
有什么解决办法吗?
HTML 样式
要使用此模式,请在 parse_mode 字段中传递 HTML。目前支持以下标签:
<b>bold</b>, <strong>bold</strong>
<i>italic</i>, <em>italic</em>
<u>underline</u>, <ins>underline</ins>
<s>strikethrough</s>, <strike>strikethrough</strike>, <del>strikethrough</del>
<b>bold <i>italic bold <s>italic bold strikethrough</s> <u>underline italic bold</u></i> bold</b>
<a href="http://www.example.com/">inline URL</a>
<a href="tg://user?id=123456789">inline mention of a user</a>
<code>inline fixed-width code</code>
<pre>pre-formatted fixed-width code block</pre>
<pre><code class="language-python">pre-formatted fixed-width code block written in the Python programming language</code></pre>
【问题讨论】:
-
无法在 Telegram 中使用颜色设置文本样式。
标签: telegram telegram-bot