yagop / node-telegram-bot-api

Telegram Bot API for NodeJS
MIT License
8.31k stars 1.51k forks source link

Support for Telegram Bot API 6.0 #966

Closed danielperez9430 closed 2 years ago

danielperez9430 commented 2 years ago

Description

Telegram Bot API 6.0

References

danielperez9430 commented 2 years ago

Use examples:

    bot.setChatMenuButton({
        chat_id: msg.chat.id,
        menu_button: JSON.stringify({ type: "web_app", text: "Hello", web_app: { url: "https://webappcontent.telegram.org/cafe" } })
    })
        .then(res => {
            console.log("Result -> " + res);
        })

    // Optional parameter "{ chat_id : msg.chat.id }"
    bot.getChatMenuButton().then(res => {
        console.log("ChatMenuButton -> ", res);
    })

    bot.setMyDefaultAdministratorRights({
        rights: JSON.stringify({
            can_manage_chat: true,
            can_change_info: true,
            can_delete_messages: false,
            can_invite_users: true,
            can_restrict_members: false,
            can_pin_messages: true,
            can_promote_members: false,
            can_manage_video_chats: false,
            is_anonymous: false
        }),
        for_channels: false
    })
        .then(res => {
            console.log("Set success? -> " + res);

            bot.getMyDefaultAdministratorRights({ for_channels: false }).then(res => {
                console.log("MyDefaultAdministratorRights -> ", res);
            })
        })

Open a web bot from keyboard / inline button:

    bot.sendMessage(msg.chat.id, "Open web bot with your keyboard button",
        {
            reply_markup: {
                keyboard: [[
                    {
                        text: "Open simple mode",
                        web_app: { url: "https://webappcontent.telegram.org/cafe" }
                    }
                ]],
            }
        }
    )

    bot.sendMessage(msg.chat.id, "Open web bot with button below",
    {
        reply_markup: {
            inline_keyboard: [[
                {
                    text: "Open demo",
                    web_app: { url: "https://webappcontent.telegram.org/cafe" }
                }
            ]],
        }
    }