You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Telegram超级组中new_chat_members/chat_member事件未触发问题

Telegram超级组中new_chat_members/chat_member事件无法触发

我用Telegraf开发Telegram机器人,目的是监听用户加入群组的new_chat_members事件,但在超级组环境下该事件完全无法触发——即使机器人已经拥有所需的管理员权限。我尝试切换为chat_member事件,问题依然存在。

以下是相关信息:

机器人在群组中的权限信息

{
    "result": {
        "user": {
            "id": "ID_BOT",
            "is_bot": true,
            "first_name": "NAME_BOT",
            "username": "USER_NAME_BOT"
        },
        "status": "administrator",
        "can_be_edited": false,
        "can_manage_chat": true,
        "can_change_info": true,
        "can_delete_messages": true,
        "can_invite_users": true,
        "can_restrict_members": true,
        "can_pin_messages": true,
        "can_manage_topics": false,
        "can_promote_members": false,
        "can_manage_video_chats": true,
        "can_post_stories": true,
        "can_edit_stories": true,
        "can_delete_stories": true,
        "is_anonymous": false,
        "can_manage_voice_chats": true
    }
}

超级组信息

{
    "result": {
        "id": "ID",
        "title": "TITLE",
        "username": "USERNAME",
        "type": "supergroup",
        "active_usernames": ["USERNAME"],
        "description": "This is description",
        "invite_link": "https://t.me/",
        "can_set_sticker_set": true,
        "has_visible_history": true,
        "permissions": {
            "can_send_messages": true,
            "can_send_media_messages": true,
            "can_send_audios": false,
            "can_send_documents": false,
            "can_send_photos": true,
            "can_send_videos": false,
            "can_send_video_notes": false,
            "can_send_voice_notes": false,
            "can_send_polls": false,
            "can_send_other_messages": true,
            "can_add_web_page_previews": true,
            "can_change_info": false,
            "can_invite_users": false,
            "can_pin_messages": false,
            "can_manage_topics": false
        },
        "join_to_send_messages": true,
        "has_hidden_members": true,
        "max_reaction_count": 11,
        "accent_color_id": 6
    }
}

我的代码

require('dotenv').config();
const { Telegraf } = require('telegraf');
const axios = require('axios');

// Constant & data
const bot = new Telegraf(process.env.TELEGRAM_BOT_TOKEN, { handlerTimeout: 9_000_000 });

// Start & Help
bot.on('new_chat_members', async (ctx) => {
    try {
        for (const user of ctx.message.new_chat_members) {
            if (user.is_bot) continue;
            console.log(user);
            await axios.post(`${process.env.APP_URL_API}/request/join/telegram`, { id: user.id }, {
                headers: {
                    "Content-Type": "application/json",
                }
            });
            console.log('New join', user.id);
        }
    } catch (e) {
        console.error('Error', e);
    }
});

bot.launch();

// Enable graceful stop
process.once('SIGINT', () => bot.stop('SIGINT'));
process.once('SIGTERM', () => bot.stop('SIGTERM'));

内容的提问来源于stack exchange,提问作者Arthur Odon

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.15 20:12:40