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, + } +}