Improve responses to bad commands
This commit is contained in:
parent
878d39668c
commit
1f80cd9543
@ -1,4 +1,4 @@
|
|||||||
position = [17726.0, 14957.0, 237.0]
|
position = [17726.0, 14960.0, 237.0]
|
||||||
orientation = "West"
|
orientation = "West"
|
||||||
|
|
||||||
[buy_prices]
|
[buy_prices]
|
||||||
@ -19,10 +19,10 @@ orientation = "West"
|
|||||||
"armor.misc.head.boreal_warhelm" = 450_000
|
"armor.misc.head.boreal_warhelm" = 450_000
|
||||||
|
|
||||||
# Hats
|
# Hats
|
||||||
"armor.misc.head.cat_capuche" = 700_000
|
"armor.misc.head.cat_capuche" = 750_000
|
||||||
"armor.misc.head.hare_hat" = 100_000
|
"armor.misc.head.hare_hat" = 150_000
|
||||||
"armor.misc.head.winged_coronet" = 40_000
|
"armor.misc.head.winged_coronet" = 40_000
|
||||||
"calendar.christmas.armor.misc.head.woolly_wintercap" = 800_000
|
"calendar.christmas.armor.misc.head.woolly_wintercap" = 250_000
|
||||||
|
|
||||||
# Crafting
|
# Crafting
|
||||||
"crafting_ing.alkahest" = 6_000
|
"crafting_ing.alkahest" = 6_000
|
||||||
|
30
src/bot.rs
30
src/bot.rs
@ -133,7 +133,7 @@ impl Bot {
|
|||||||
if self.last_announcement.elapsed() > Duration::from_secs(1200) {
|
if self.last_announcement.elapsed() > Duration::from_secs(1200) {
|
||||||
self.client.send_command(
|
self.client.send_command(
|
||||||
"region".to_string(),
|
"region".to_string(),
|
||||||
vec!["I'm a bot. You can trade with me or use /say or /tell to check prices: 'price [item_name]'".to_string()],
|
vec!["I'm a bot. You can trade with me or use /say or /tell to check prices: 'price [search_term]'".to_string()],
|
||||||
);
|
);
|
||||||
|
|
||||||
self.last_announcement = Instant::now();
|
self.last_announcement = Instant::now();
|
||||||
@ -155,21 +155,43 @@ impl Bot {
|
|||||||
_ => return Ok(()),
|
_ => return Ok(()),
|
||||||
};
|
};
|
||||||
let content = message.content().as_plain().unwrap_or_default();
|
let content = message.content().as_plain().unwrap_or_default();
|
||||||
let (command, item_name) = content.split_once(' ').unwrap_or((content, ""));
|
let mut split_content = content.split(' ');
|
||||||
let item_name = item_name.to_lowercase();
|
let command = split_content.next().unwrap_or_default();
|
||||||
|
let mut is_correct_format = false;
|
||||||
|
|
||||||
match command {
|
match command {
|
||||||
"price" => {
|
"price" => {
|
||||||
self.send_price_info(&sender, &item_name)?;
|
for item_name in split_content {
|
||||||
|
self.send_price_info(&sender, &item_name.to_lowercase())?;
|
||||||
|
|
||||||
|
is_correct_format = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
"take" => {
|
"take" => {
|
||||||
if !self.client.is_trading() {
|
if !self.client.is_trading() {
|
||||||
self.trade_mode = TradeMode::Take;
|
self.trade_mode = TradeMode::Take;
|
||||||
self.client.send_invite(sender, InviteKind::Trade);
|
self.client.send_invite(sender, InviteKind::Trade);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
is_correct_format = true;
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !is_correct_format {
|
||||||
|
let player_name = self
|
||||||
|
.find_name(&sender)
|
||||||
|
.ok_or("Failed to find player name")?
|
||||||
|
.to_string();
|
||||||
|
|
||||||
|
self.client.send_command(
|
||||||
|
"tell".to_string(),
|
||||||
|
vec![
|
||||||
|
player_name.clone(),
|
||||||
|
format!("Use the format 'price [search_term]'."),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
VelorenEvent::Outcome(Outcome::ProjectileHit {
|
VelorenEvent::Outcome(Outcome::ProjectileHit {
|
||||||
target: Some(target),
|
target: Some(target),
|
||||||
|
Loading…
Reference in New Issue
Block a user