Telegram API with Google Apps Script

前端 未结 2 1021
故里飘歌
故里飘歌 2021-02-09 07:13

I\'m searching an example of Telegram API usage with Google Apps Script, or anyone/anything that can help me to learn how to use this API, for instance to send a message to a ce

2条回答
  •  暖寄归人
    2021-02-09 08:07

    I was searching for something similar, and couldn't find any, so I have made my own, I will write it down here perhaps someone would make use of it.

    This is a simple proof of concept that works:

    function sendTelegramNotification(botSecret, chatId, body) {
    var response = UrlFetchApp.fetch("https://api.telegram.org/bot" + botSecret + "/sendMessage?text=" + encodeURIComponent(body) + "&chat_id=" + chatId + "&parse_mode=HTML");
    }
    

    Other commands can be made same way.

提交回复
热议问题