Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
qdk0901 opened this issue Dec 4, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@qdk0901
Copy link

qdk0901 commented Dec 4, 2024

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 qdk0901 added the bug Something isn't working label Dec 4, 2024
@qdk0901
Copy link
Author

qdk0901 commented Dec 4, 2024

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

@borzovplus
Copy link

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

@borzovplus
Copy link

Channel - ids starts with -100
Chat - other ids

@qdk0901
Copy link
Author

qdk0901 commented Dec 5, 2024

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}")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants