我们如何通过Google Sheets应用程序脚本控制Telegram Bot彩色文本



我们可以格式化彩色文本消息并发送FormattedMessage吗?

使用JavaScript+Google Web应用程序与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>

我不确定它是否仍然与您相关,但他们有一个API方法来启用htmlMode。

例如,在java中,它将是:

message.enableHtml(true);

您还可以使用html标记和css样式来包装您的消息。

String message_text = "<b>" + update.getMessage().getFrom().getFirstName() + "</b>" + " Said what? n" + update.getMessage().getText();

最新更新