Improve error handling and maybe fix war feed
This commit is contained in:
parent
ef74def35d
commit
4c6ee35ac7
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -1206,7 +1206,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wynnrobot"
|
||||
version = "0.11.0"
|
||||
version = "0.11.1"
|
||||
dependencies = [
|
||||
"configure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"diesel 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1,7 +1,7 @@
|
||||
[package]
|
||||
authors = ["Sakuhl <2012collector@gmail.com>"]
|
||||
name = "wynnrobot"
|
||||
version = "0.11.0"
|
||||
version = "0.11.1"
|
||||
|
||||
[dependencies]
|
||||
configure = "0.1.1"
|
||||
|
@ -65,7 +65,7 @@ pub fn war_livefeed() {
|
||||
let mut players: Value = serde_json::from_reader(resp).unwrap();
|
||||
|
||||
loop {
|
||||
thread::sleep_ms(50_000); // 50 seconds
|
||||
thread::sleep_ms(30_000); // 30 seconds
|
||||
let resp = reqwest::get("https://api.wynncraft.com/public_api.php?action=onlinePlayers").unwrap();
|
||||
|
||||
let new_players: Value = serde_json::from_reader(resp).unwrap();
|
||||
|
@ -13,6 +13,9 @@ use failure::Error;
|
||||
use ::ResponseError;
|
||||
|
||||
pub fn wc_guild(command: &str, msg: &Message) -> Result<(), Error> {
|
||||
if command.len() <= 6 {
|
||||
bail!("no guild specified");
|
||||
}
|
||||
let guild_name = &command[6..];
|
||||
|
||||
let guild;
|
||||
|
@ -65,6 +65,10 @@ pub fn wc_status(msg: &Message) -> Result<(), Error> {
|
||||
}
|
||||
|
||||
pub fn wc_territory(command: &str, msg: &Message) -> Result<(), Error> {
|
||||
if command.len() <= 10 {
|
||||
bail!("no territory specified");
|
||||
}
|
||||
|
||||
let territory = &command[10..];
|
||||
|
||||
let resp = reqwest::get("https://api.wynncraft.com/public_api.php?action=territoryList")?.text().unwrap();
|
||||
|
@ -5,6 +5,9 @@ use serenity::model::*;
|
||||
use failure::Error;
|
||||
|
||||
pub fn wc_player(command: &str, msg: &Message) -> Result<(), Error> {
|
||||
if command.len() <= 7 {
|
||||
bail!("no player specified");
|
||||
}
|
||||
let player = &command[7..];
|
||||
|
||||
let player = wynncraft::player(player)?;
|
||||
|
16
src/main.rs
16
src/main.rs
@ -141,21 +141,21 @@ impl Handler {
|
||||
}
|
||||
let command = &msg.content[prefix.len()..];
|
||||
|
||||
if command.starts_with("guild ") {
|
||||
if command.starts_with("guild") {
|
||||
wc_guild(command, msg)?;
|
||||
} else if command == "topguilds" {
|
||||
wc_topguilds_limit(msg, 10)?;
|
||||
} else if command.starts_with("topguilds ") {
|
||||
wc_topguilds(command, msg)?;
|
||||
} else if command.starts_with("territory ") {
|
||||
} else if command.starts_with("territory") {
|
||||
wc_territory(command, msg)?;
|
||||
} else if command == "status" {
|
||||
wc_status(msg)?;
|
||||
} else if command.starts_with("player ") {
|
||||
} else if command.starts_with("player") {
|
||||
wc_player(command, msg)?;
|
||||
} else if command == "livefeed" {
|
||||
} else if command.starts_with("livefeed") {
|
||||
wc_livefeed(msg)?;
|
||||
} else if command == "unlivefeed" {
|
||||
} else if command.starts_with("unlivefeed") {
|
||||
wc_unlivefeed(msg)?;
|
||||
} else if command == "info" || command == "" {
|
||||
wc_info(msg)?;
|
||||
@ -165,9 +165,9 @@ impl Handler {
|
||||
wc_crop(command, msg)?;
|
||||
} else if command == "crop" {
|
||||
wc_crop_discord_upload(msg)?;
|
||||
} else if command == "warfeed" {
|
||||
} else if command.starts_with("warfeed") {
|
||||
wc_warfeed(msg)?;
|
||||
} else if command == "unwarfeed" {
|
||||
} else if command.starts_with("unwarfeed") {
|
||||
wc_unwarfeed(msg)?;
|
||||
} else if command.starts_with("shout") {
|
||||
if msg.author.name == "Wurst" && msg.author.discriminator == 1783 {
|
||||
@ -175,7 +175,7 @@ impl Handler {
|
||||
} else {
|
||||
"<@210743594061922306>".parse::<User>().unwrap().dm(|f| f.content(format!("{} tried to shout {:?}", msg.author, &command[6..]))).unwrap();
|
||||
}
|
||||
} else if command.starts_with("prefix ") {
|
||||
} else if command.starts_with("prefix") {
|
||||
wc_prefix(command, msg)?;
|
||||
} else {
|
||||
bail!(ResponseError::UnknownCommand { name: command.to_owned() });
|
||||
|
Loading…
Reference in New Issue
Block a user