是否可以调整此功能以与电子表格中的ARRAYFORMULA
一起使用?
function SendTelegram(botSecret, chatId, body) {
var response = UrlFetchApp.fetch("https://api.telegram.org/bot" + botSecret + "/sendMessage?text=" + encodeURIComponent(body) + "&chat_id=" + chatId + "&parse_mode=HTML");
}
不要像这样对每行使用公式:
=SendTelegram($H$1,$I$1,F2)
=SendTelegram($H$1,$I$1,F3)
=SendTelegram($H$1,$I$1,F4)
=SendTelegram($H$1,$I$1,F5)
通过这种方式:
=ARRAYFORMULA(SendTelegram($H$1,$I$1,F2:F))
返回以下消息:
Limit Exceeded: URLFetch URL Length. (line 22).
答案 0 :(得分:2)
类似的事情,您可能必须适应所需的特定行为。
function SendTelegram(botSecret, chatId, body) {
if (body.map) { // is array?
var response = body.map(function(b) {return SendTelegram(botSecret,chatId,b);});
} else {
var response = UrlFetchApp.fetch("https://api.telegram.org/bot" + botSecret + "/sendMessage?text=" + encodeURIComponent(body) + "&chat_id=" + chatId + "&parse_mode=HTML");
}
}