Lonami / grammers

(tele)gramme.rs - use Telegram's API from Rust
https://t.me/gramme_rs
Apache License 2.0
535 stars 103 forks source link

[Q] Is it possible to make public access to chat hashes for the client structure or to make it try to find chat hashes in its state #211

Closed taimast closed 9 months ago

taimast commented 9 months ago

Is it possible to make public access to chat hashes for the client structure or to make it try to find chat hashes in its state. For example, I want to send a message to the users who wrote to me, and I saved only their id, and when using

let mut im = InputMessage::html(text.clone());
            im = im.link_preview(true);
            client.send_message(
                PackedChat {
                    ty: PackedType::User,
                    id: user_id,
                    access_hash:None,
                },
                im,
            ).await?;

I can get the USER_ID_INVALID error for most chats due to the lack of hashes

Maybe this is not the best idea and I missed something and there are better alternatives than saving PackedChat, I would like to hear your opinion

Lonami commented 9 months ago

and I saved only their id

No, you're expected to save the entire packed chat.

and there are better alternatives than saving PackedChat

Someone needs to save it. Telethon v1 does. Telethon v2 and grammers won't. This has the benefit of not relying on some implicit hidden mechanism. It's explicit and up to you how to save it.