Skip to content

Telegram: incorrect sender identification for messages from channels #9719

@xaker01

Description

@xaker01

In src/telegram/bot-message-context.ts (line ~405):

const senderId = msg.from?.id ? String(msg.from.id) : "";

Problem:

• When a channel posts to a group → msg.from?.id = fake system ID (all channels appear as one sender)
• When a user posts to a group → msg.from?.id = real ID (correct)
When a message comes from a channel, there is no sender/user — the source is the channel itself with msg.sender_chat.id.

Solution:

const senderId = msg.sender_chat?.id ?? msg.from?.id ? String(msg.sender_chat?.id ?? msg.from?.id) : "";

This correctly handles both cases:

• Channel message → use sender_chat.id (real source)
• User message → use from.id (real sender)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstaleMarked as stale due to inactivity

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions