Browse Source

Add time output to the bot

master
Jirka Sejkora 4 years ago
parent
commit
c8dc4e064d
  1. 52
      Cargo.lock
  2. 1
      Cargo.toml
  3. 6
      src/upload-bot.rs

52
Cargo.lock

@ -75,6 +75,19 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "chrono"
version = "0.4.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73"
dependencies = [
"libc",
"num-integer",
"num-traits",
"time",
"winapi",
]
[[package]] [[package]]
name = "cloudabi" name = "cloudabi"
version = "0.0.3" version = "0.0.3"
@ -307,7 +320,7 @@ checksum = "ee8025cf36f917e6a52cce185b7c7177689b838b7ec138364e50cc2277a56cf4"
dependencies = [ dependencies = [
"cfg-if 0.1.10", "cfg-if 0.1.10",
"libc", "libc",
"wasi", "wasi 0.9.0+wasi-snapshot-preview1",
] ]
[[package]] [[package]]
@ -640,6 +653,25 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "num-integer"
version = "0.1.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db"
dependencies = [
"autocfg 1.0.1",
"num-traits",
]
[[package]]
name = "num-traits"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290"
dependencies = [
"autocfg 1.0.1",
]
[[package]] [[package]]
name = "num_cpus" name = "num_cpus"
version = "1.13.0" version = "1.13.0"
@ -808,6 +840,7 @@ name = "prague"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"byteorder", "byteorder",
"chrono",
"indicatif", "indicatif",
"itertools", "itertools",
"rand 0.8.0", "rand 0.8.0",
@ -1349,6 +1382,17 @@ dependencies = [
"lazy_static", "lazy_static",
] ]
[[package]]
name = "time"
version = "0.1.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255"
dependencies = [
"libc",
"wasi 0.10.0+wasi-snapshot-preview1",
"winapi",
]
[[package]] [[package]]
name = "tinyvec" name = "tinyvec"
version = "1.1.1" version = "1.1.1"
@ -1521,6 +1565,12 @@ version = "0.9.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
[[package]]
name = "wasi"
version = "0.10.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f"
[[package]] [[package]]
name = "wasm-bindgen" name = "wasm-bindgen"
version = "0.2.70" version = "0.2.70"

1
Cargo.toml

@ -15,6 +15,7 @@ rusqlite = "0.24.2"
regex = "1.4.3" regex = "1.4.3"
rayon = "1.5.0" rayon = "1.5.0"
soup = "0.5.0" soup = "0.5.0"
chrono = "0.4.19"
[dependencies.reqwest] [dependencies.reqwest]
version = "0.11.0" version = "0.11.0"

6
src/upload-bot.rs

@ -5,8 +5,9 @@ use soup::prelude::*;
use std::fmt::Write; use std::fmt::Write;
use std::io::Error; use std::io::Error;
use std::thread::sleep; use std::thread::sleep;
use std::time::Duration;
use std::process::exit; use std::process::exit;
use std::time::Duration;
use chrono::Local;
mod optimization; mod optimization;
mod city; mod city;
@ -30,7 +31,8 @@ fn main() {
loop { loop {
if let Some((contestant, score)) = get_top_score() { if let Some((contestant, score)) = get_top_score() {
eprintln!("Top score found: {} by {}", score, contestant); let time = Local::now();
eprintln!("[{}] Top score found: {} by {}", time.format("%H:%M:%S"), score, contestant);
if contestant != "Jirka Sejkora (org)" { if contestant != "Jirka Sejkora (org)" {
eprintln!("Wrong contestant, trying to one-up."); eprintln!("Wrong contestant, trying to one-up.");

Loading…
Cancel
Save