Уведомления в Telegram (Телеграм)

Материал из Sprut.hub Wiki
let chatIDs = ["666666666"];
let token = "666666666:AABBCCddEeffggeeHH-IIJJkKLlMmnno_oP"

function sendToTelegram(text, notify) {
    try {
        if (!Array.isArray(text))
            text = [text];

        chatIDs.forEach(function (chatID) {
            HttpClient.POST("https://api.telegram.org")
                .path("bot" + token)
                .path("sendMessage")
                .queryString("chat_id", chatID)
                .queryString("text", text.join("\n"))
                .queryString("parse_mode", "Markdown")
                .queryString("disable_notification", notify == null ? false : !notify)
                .send()
        })
    } catch (e) {
        log.error(e.message);
    }
}