Telegram Bot - how to get a group chat id?

后端 未结 12 1107
北海茫月
北海茫月 2020-11-30 16:42

I\'ve been using telegram_bot, and trying to get groupChat id to send notifications to group chat, but don\'t know which methods I have to use for it.

For getting ch

12条回答
  •  借酒劲吻你
    2020-11-30 17:19

    bot receives the following message originated on a Telegram group having a bot co-existing:

    extract data as required

    function doPost(e) {
        var contents = JSON.parse(e.postData.contents);
        //  GmailApp.sendEmail(Session.getEffectiveUser().getEmail(), "Telegram Bot Update", JSON.stringify(contents, null, 4));
        var chat_id = contents.message.chat.id;
        var text = contents.message.text;
        var name = contents.message.from.first_name + " " +  contents.message.from.last_name;
        var sResponse = telegramBotMachine( chat_id, text, name );
    }  
    

    /* contents

    {
        "update_id": 20383255,
        "message": {
            "message_id": 147,
            "from": {
                "id": 999999999,
                "is_bot": false,
                "first_name": "Trajano",
                "last_name": "Roberto",
                "username": "TrajanoRoberto",
                "language_code": "en"
            },
            "chat": {
                "id": -666666666,
                "title": "Test Ataque Media Flamengo",
                "type": "group",
                "all_members_are_administrators": true
            },
            "date": 1585450075,
            "text": "Menu"
        }
    }
    

提交回复
热议问题