Lonami / grammers

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

Panic when call Client::join_chat, unwrap on None value. #286

Closed RuofengX closed 3 weeks ago

RuofengX commented 3 weeks ago
thread 'tokio-runtime-worker' panicked at ~/.cargo/git/checkouts/grammers-689e30b82f69dcd5/8997a2d/lib/grammers-client/src/client/chats.rs:823:54:
called `Option::unwrap()` on a `None` value

After post this issue I realize that I am not working on the latest commit, so I ran cargo update then run my program, the panic still:

thread 'tokio-runtime-worker' panicked at ~/.cargo/git/checkouts/grammers-689e30b82f69dcd5/6a3cdbe/lib/grammers-client/src/client/chats.rs:842:54:
called `Option::unwrap()` on a `None` value
RuofengX commented 3 weeks ago

try_to_input_channel() seems return a None value. https://github.com/Lonami/grammers/blob/6a3cdbe122f9e5d733bd61d38b3daa993d4613ce/lib/grammers-client/src/client/chats.rs#L842

RuofengX commented 3 weeks ago

It can confirmed that this issue surely happens when provide a id of a quited chat with a user(or bot) to join_chat function.

RuofengX commented 3 weeks ago

Join group also have same issue. Join channel is ok for now.

I am using cached packed chat to join a group/bot after quitting them, is that the reason? Or does packed chat data became invalid after quit?

Lonami commented 3 weeks ago

Only public channels can be joined with this request, but it's true the library should not panic.

Packed chats are only valid in the session that acquired them. Logging in to the same account is considered a new session. But the panic here is trying to join something other than a channel.