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

feat(message-row): Add initial support for replies chat #467

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

alissonlauffer
Copy link
Contributor

@alissonlauffer alissonlauffer commented Feb 11, 2023

This PR adds basic support for the "Replies" chat.

Things like showing replied messages and a button to view the original message should be addressed in other issues.

Closes #465.

src/tdlib/chat.rs Outdated Show resolved Hide resolved
src/components/avatar.rs Outdated Show resolved Hide resolved
src/components/avatar.rs Outdated Show resolved Hide resolved
@@ -481,6 +481,10 @@ impl Chat {
self.type_().user() == Some(&self.session().me())
}

pub(crate) fn is_replies_chat(&self) -> bool {
self.id() == 1271266957 || self.id() == 708513
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it have two ids?

Copy link
Contributor Author

@alissonlauffer alissonlauffer Mar 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The second id is there because the second id is of the test backend bot.
This is also the same way Telegram Desktop implements it (with the exception that it also checks the current backend, but imo it's not needed): https://github.com/telegramdesktop/tdesktop/blob/41d9a9fcbd0c809c60ddbd9350791b1436aff7d9/Telegram/SourceFiles/data/data_peer.cpp#L891

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alissonlauffer Could one of the ids collide with a regular chat? I would suggest to use this

pub(crate) fn is_replies_chat(&self) -> bool {
        (self.session_().client_().database_info().0.use_test_dc && self.id() == 708513)
            || self.id() == 1271266957
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, actually, Marco suggested to handle UpdateOption instead (which includes a replies_bot_chat_id option), but I'm not sure how to correctly add support to tdlib options, since keys are just strings, and values can be of any type. Tdlib options are a nice thing to have in the session object, but it could be implemented in another PR, which could be merged before this one.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean basically?
grafik

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but we would need too much "boilerplate code" to do that, in my opinion.
But we can add tdlib options on demand also, there's no need to add all of them right away.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can add tdlib options on demand also.

What do you mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, right now we would only require replies_bot_chat_id, but in the future, if we need more options, we could add one by one. But yeah, this could become an excuse for not using them.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, at Some point we should start using them. 😆
I think using this option is the correct future-proof way, as we never know whether telegram might suddenly change such a magic id.

@melix99 melix99 added this to the Telegrand 0.1 milestone Mar 22, 2023
@alissonlauffer alissonlauffer force-pushed the replies-chat branch 2 times, most recently from 177eec4 to 1d6994b Compare March 23, 2023 15:41
@alissonlauffer alissonlauffer force-pushed the replies-chat branch 2 times, most recently from 4b97196 to ce30f16 Compare June 15, 2023 21:55
@alissonlauffer alissonlauffer changed the title message-row: Add initial support for replies chat feat(message-row): Add initial support for replies chat Jun 15, 2023
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.

Support @replies custom chat on telegram
4 participants