Skip to content

getSender() returns a user ID instead of a bot ID #130

Description

@chimit

When the bot receives an incoming message from itself in the Heard middleware, $message->getSender() returns a user Telegram ID instead of a bot Telegram ID.

In the example below, I log messages from bots:

if (data_get($message->getPayload(), 'from.is_bot') === true) {
    Log::debug('Catch bot messages.', [
        'getSender' => $message->getSender(),
        'payload' => $message->getPayload(),
    ]);
}

The incoming message is a bot message. Bot Telegram ID is 2222222222 which is clearly visible in the payload in from.id, but $message->getSender() for some reason returns a different Telegram ID of 11111111 (which is an ID of a user in that chat):

{
    "getSender": 11111111,
    "payload": {
        "message_id": 1328846,
        "from": {
            "id": 2222222222,
            "is_bot": true,
            "first_name": "My bot name",
            "username": "somebotname"
        },
        "chat": {
            "id": -3333333333,
            "title": "Some chat name",
            "type": "group",
            "all_members_are_administrators": true,
            "accepted_gift_types": {
                "unlimited_gifts": false,
                "limited_gifts": false,
                "unique_gifts": false,
                "premium_subscription": false
            }
        },
        "date": 1757250577,
        "text": "Bot response"
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions