Skip to content

Add support for cross-chat replies. - #6

Open
ALiwoto wants to merge 1 commit into
AmanoTeam:masterfrom
ALiwoto:add_crossChatSupport
Open

Add support for cross-chat replies.#6
ALiwoto wants to merge 1 commit into
AmanoTeam:masterfrom
ALiwoto:add_crossChatSupport

Conversation

@ALiwoto

@ALiwoto ALiwoto commented Nov 1, 2023

Copy link
Copy Markdown
Member

New telegram update added a new feature called cross-chat replies: you can reply to messages which are sent in other chats.
Currently pyrogram cannot parse such messages (updates/commands will not get triggered; get_messages will raise InvalidMsgId exception, etc).

This pull request adds support for fetching cross-chat replies.

Signed-off-by: Aliwoto <woto@kaizoku.cyou>
@alissonlauffer

Copy link
Copy Markdown
Member

Thanks, but doesn't this require a schema update to work?

@ALiwoto

ALiwoto commented Nov 2, 2023

Copy link
Copy Markdown
Member Author

Thanks, but doesn't this require a schema update to work?

Oh I thought your tl is updated to latest layer, let me see

@ALiwoto

ALiwoto commented Nov 2, 2023

Copy link
Copy Markdown
Member Author

@alissonlauffer I just checked

https://github.com/AmanoTeam/pyrogram/blob/16cf07c5ad38085b2769bd86b46569ec254e3f3a/compiler/api/source/main_api.tl#L1267C114-L1267C130

looks like your scheme supports parsing reply_to_peer_id and reply_to (I did also put attribute checks just to be sure), so I think it will work.
What doesn't work is, you trying to reply cross-chat (e.g. you send a reply to another chat, which isn't supported in layer 162)
I didn't implement that here anyway

@ALiwoto

ALiwoto commented Nov 2, 2023

Copy link
Copy Markdown
Member Author

Btw, I have also implemented cross-chat replies in send_message method (and similar methods, like send_animation and so on).
In this commit.

But that requires latest layer, so yeah.

@alissonlauffer

Copy link
Copy Markdown
Member

I see that you added the is_cross_chat property to Message by using a setattr, which is not a good idea. The best approach here would be adding a new bool attribute to the Message object, and set it later with parsed_message.is_cross_chat = ....
Also, I'm not sure if these hasattrs are useful, since values that exist are None, and would thus break the condition.

Last thing, It'd be better if you use utils.get_channel_id(chat_id) instead of adding a leading -100 using a f-string, which also makes the chat_id become a string instead of an integer.

@alissonlauffer

Copy link
Copy Markdown
Member

Ah, before I forget, do you know how does the bot API handles this? Since Pyrogram is intended to be a MTProto client with a similar API to that of the bot API.

@ALiwoto

ALiwoto commented Nov 2, 2023

Copy link
Copy Markdown
Member Author

@alissonlauffer bot api doesn't handle this yet

@ALiwoto

ALiwoto commented Nov 2, 2023

Copy link
Copy Markdown
Member Author

We have lots of bot api bots in our groups, one of them is a group management one
If you cross-reply a blacklisted word, the bot just won't get triggered

@ALiwoto

ALiwoto commented Nov 2, 2023

Copy link
Copy Markdown
Member Author

Oh btw, about is_cross_chat attr, yeah, I was just doing that for debug purposes in my own fork, was planning to remove it later on, forgot
feel free to remove it

@alissonlauffer

Copy link
Copy Markdown
Member

Well, I'll keep this PR open for a while, because it needs some manual changes, and I'm also a bit busy with a new project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants