From 0b60396f81c1cf37824977316d6445352016abe7 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Thu, 13 Feb 2020 16:57:44 -0500 Subject: [PATCH] Do not try to call Codeforces API when there's no channels to send --- youmubot-cf/src/announcer.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/youmubot-cf/src/announcer.rs b/youmubot-cf/src/announcer.rs index 3729423..e324990 100644 --- a/youmubot-cf/src/announcer.rs +++ b/youmubot-cf/src/announcer.rs @@ -58,11 +58,11 @@ fn update_user( cfu.rating = info.rating; let mut send_message = |rc: RatingChange| -> CommandResult { - let (contest, _, _) = - codeforces::Contest::standings(reqwest, rc.contest_id, |f| f.limit(1, 1))?; let channels = channels_list.get_or_insert_with(|| channels.channels_of(http.clone(), user_id)); - for channel in channels { + if channels.is_empty() { return Ok(()); } + let (contest, _, _) = + codeforces::Contest::standings(reqwest, rc.contest_id, |f| f.limit(1, 1))?; for channel in channels { if let Err(e) = channel.send_message(http.http(), |e| { e.content(format!("Rating change for {}!", user_id.mention())) .embed(|c| {