td icon indicating copy to clipboard operation
td copied to clipboard

Cannot receive message from super group, and ChatID for normal group not correct

Open qdk0901 opened this issue 1 year ago • 4 comments

What version of gotd are you using?

github.com/gotd/td v0.115.0

Can this issue be reproduced with the latest version?

Yes

What did you do?

Just run echo bot example

What did you expect to see?

should echo in super group, it echo as expected in normal Telegram group I test the same bot(same appId, appHash, botToken) with pyrogram, pyrogram can receive message from the same super group

What did you see instead?

nothing

What Go version and environment are you using?

`` go version go1.23.3 windows/amd64


And there is another bug, the ChatID from group or super group should be negative

qdk0901 avatar Dec 04 '24 07:12 qdk0901

it's weird, the telegram super group message is actually NewChannelMessage ?

qdk0901 avatar Dec 04 '24 09:12 qdk0901

This is the specifics of Telegram's work, not the library's

borzovplus avatar Dec 04 '24 12:12 borzovplus

Channel - ids starts with -100 Chat - other ids

borzovplus avatar Dec 04 '24 12:12 borzovplus

Channel - ids starts with -100 Chat - other ids

ok, finally I figure out that pyrogram do a convertion for channel/chat/user id just for convenience, in the telegram protocol, all ids are positive

https://github.com/pyrogram/pyrogram/blob/master/pyrogram/utils.py

def get_peer_id(peer: raw.base.Peer) -> int:
    """Get the non-raw peer id from a Peer object"""
    if isinstance(peer, raw.types.PeerUser):
        return peer.user_id

    if isinstance(peer, raw.types.PeerChat):
        return -peer.chat_id

    if isinstance(peer, raw.types.PeerChannel):
        return MAX_CHANNEL_ID - peer.channel_id

    raise ValueError(f"Peer type invalid: {peer}")

qdk0901 avatar Dec 05 '24 10:12 qdk0901