Add polish

This commit is contained in:
Jeff 2024-07-08 20:20:29 -04:00
parent 27bb52153b
commit a66f65058f

View File

@ -135,7 +135,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. Trade with me or say 'prices' to see my offers.".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()],
); );
self.last_announcement = Instant::now(); self.last_announcement = Instant::now();
@ -161,22 +161,32 @@ impl Bot {
match command { match command {
"price" => { "price" => {
for (item_id, price) in &self.buy_prices {
if item_id.contains(item_name) {
let player_name = self let player_name = self
.find_name(&sender) .find_name(&sender)
.ok_or("Failed to find player name")? .ok_or("Failed to find player name")?
.to_string(); .to_string();
let mut found = false;
for (item_id, price) in &self.buy_prices {
if item_id.contains(item_name) {
self.client.send_command( self.client.send_command(
"tell".to_string(), "tell".to_string(),
vec![ vec![
player_name.clone(), player_name.clone(),
format!("{item_id} costs {price} coins"), format!("{item_id} costs {price} coins."),
], ],
); );
found = true;
} }
} }
if !found {
self.client.send_command(
"tell".to_string(),
vec![player_name.clone(), format!("I don't have that item.")],
);
}
} }
"prices" => self.send_all_price_info(&sender)?, "prices" => self.send_all_price_info(&sender)?,
"take" => { "take" => {