Commit 28d10fcd authored by Frederick Zhang's avatar Frederick Zhang
Browse files

sometimes we need to wait

parent 61a91b32
[package]
name = "ds-proj1-bot"
version = "0.1.1"
version = "0.1.2"
authors = ["Frederick Zhang <[email protected]>"]
[dependencies]
......
......@@ -251,6 +251,8 @@ true
4
#contain
roomchange
#wait
200
#write
5
{"type":"list"}
......
......@@ -7,6 +7,8 @@ use std::io::BufReader;
use std::fs::File;
use std::str;
use std::collections::HashMap;
use std::thread::sleep;
use std::time::Duration;
use regex::Regex;
......@@ -123,6 +125,14 @@ fn main() {
println!("Not Con: {}", expected);
}
}
"#wait" => {
let duration = &commands[i + 1];
let ms: u64 = duration.parse::<u64>().unwrap();
let duration: Duration = Duration::new(ms / 1000u64,
((ms % 1000) as u32) * 1000000);
println!("Wait : {}", ms);
sleep(duration);
}
"#quit" => {
println!("All test passed! Congrats!");
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment