From f79582c3fcb8a3e6520e2f115cb83e4eb294c8f7 Mon Sep 17 00:00:00 2001 From: JasterV Date: Sat, 4 Sep 2021 00:15:45 +0200 Subject: [PATCH] bug solucionao --- src/main.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index dfab84b..4c02c35 100644 --- a/src/main.rs +++ b/src/main.rs @@ -68,9 +68,8 @@ async fn execute(cx: Cx, command: Command) -> Result<()> { } } _ => { - let entry = SENDERS.get(&chat_id); - if let Some(entry) = entry { - let sender = entry.value(); + let sender = get_sender(chat_id); + if let Some(sender) = sender { let _ = sender .send(GameActorMsg::Message(Message(cx, command.into()))) .await; @@ -87,3 +86,11 @@ async fn execute(cx: Cx, command: Command) -> Result<()> { } Ok(()) } + +fn get_sender(chat_id: i64) -> Option> { + let entry = SENDERS.get(&chat_id); + match entry { + Some(entry) => Some(entry.clone()), + _ => None, + } +}