diff options
| author | Nathan Perry <avaglir@gmail.com> | 2019-03-10 01:34:29 -0500 |
|---|---|---|
| committer | Nathan Perry <avaglir@gmail.com> | 2019-03-10 01:34:29 -0500 |
| commit | 364b1f9b216574c32d2aa0a699553e6328824704 (patch) | |
| tree | b0afa7b240d6307b0c75e682fef6a10fa4d4b537 | |
| parent | 33c477951e15813e78b8f76cd3f57e7d93af12be (diff) | |
finish up updategaem for now
| -rw-r--r-- | src/game.rs | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/src/game.rs b/src/game.rs index e0229ca..5911ba0 100644 --- a/src/game.rs +++ b/src/game.rs @@ -113,6 +113,8 @@ lazy_static! { }) .collect::<FnvHashMap<_, _>>() }; + + static ref ALPHABET: Vec<char> = (0..26).map(|x| (x + b'a') as char).collect(); } #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd)] @@ -365,6 +367,20 @@ fn load_spreadsheet() -> Result<Vec<Vec<String>>> { Ok(resp.value_ranges.into_iter().next().unwrap().values) } +fn to_spreadsheet_alpha(mut x: usize) -> String { + let mut result = String::new(); + + result.push(ALPHABET[x % 26]); + x /= 26; + + while x != 0 { + result.push(ALPHABET[x % 26]); + x /= 26; + } + + result.chars().rev().collect() +} + fn updategaem(_ctx: &mut Context, msg: &Message, mut args: Args) -> Result<()> { use regex::Regex; @@ -464,19 +480,20 @@ fn updategaem(_ctx: &mut Context, msg: &Message, mut args: Args) -> Result<()> { .map(|ge| ge.app_id) .collect::<FnvHashSet<_>>(); - let found = unknown_appids + let found_games = unknown_appids .filter_map(|(ai, x)| if games_owned.contains(&ai) { - Some(x.to_string()) + Some(&spreadsheet[0][x + 1]) } else { None }) - .collect::<Vec<_>>(); + .join("\n"); - if found.len() > 0 { - info!("found games at positions\n{}", found.join("\n")); + if found_games.len() > 0 { + send(msg.channel_id, &format!("you own {} games that you should add to the list:\n{}", + found_games.chars().filter(|x| *x == '\n').count() + 1, + found_games), msg.tts) } else { - info!("no games to update"); + send(msg.channel_id, "you're up to date", msg.tts) } - Ok(()) }
\ No newline at end of file |
