diff --git a/src/game/listener/host_snooper.rs b/src/game/listener/host_snooper.rs index 83d5281..af24204 100644 --- a/src/game/listener/host_snooper.rs +++ b/src/game/listener/host_snooper.rs @@ -9,6 +9,10 @@ pub struct HostSnooper {} #[async_trait] impl Listener for HostSnooper { + fn name(&self) -> String { + "Host Snooper".to_string() + } + fn get_priority(&self) -> Priority { Priority::Logging } diff --git a/src/game/listener/mod.rs b/src/game/listener/mod.rs index 5a2eb67..680c367 100644 --- a/src/game/listener/mod.rs +++ b/src/game/listener/mod.rs @@ -39,6 +39,7 @@ impl Listeners { } pub fn add_listener(&mut self, listener: Box) { + println!("Adding {} listener", listener.name()); self.listeners.push(listener); self.listeners.sort_by_key(|l1| l1.get_priority()); @@ -89,6 +90,8 @@ pub struct ListenerContext<'a> { #[async_trait] pub trait Listener: Debug + Send + Sync { + fn name(&self) -> String; + fn get_priority(&self) -> Priority { Priority::Medium } diff --git a/src/game/message_router.rs b/src/game/message_router.rs index f688e80..3cbc167 100644 --- a/src/game/message_router.rs +++ b/src/game/message_router.rs @@ -84,7 +84,7 @@ impl<'a> WoxlfMessage<'a> { Ok(match &self.source { MessageSource::Player(p) => p.codename.clone(), MessageSource::Host => global_data.game_cfg()?.bot_name.clone(), - MessageSource::Automated => "Woxlf System Message".to_string(), + MessageSource::Automated => "Woxlf Game Message".to_string(), }) } @@ -213,7 +213,7 @@ pub async fn send_to_host_channel( .get(&UserId::from(dest_player.discord_id)) .unwrap() .display_name(); - format!(" to {} ({})", dest_player.codename, name) + format!("**[DM to {} ({})]** ", dest_player.codename, name) } else { "".to_string() } @@ -222,18 +222,19 @@ pub async fn send_to_host_channel( }; let host_channel_username = format!( - "{} ({}){}", + "{} ({})", msg.get_message_username(global_data)?, source, - dest ); + let content = format!("{}{}", dest, msg.content); + send_webhook_msg( http, WebhookId::from(global_data.cfg.discord_config.host_webhook_id), &host_channel_username, Some(msg.get_profile_pic(global_data)?), - &msg.content, + &content, &msg.attachments, ) .await?; diff --git a/src/game/role/mod.rs b/src/game/role/mod.rs index 5590c97..6736f98 100644 --- a/src/game/role/mod.rs +++ b/src/game/role/mod.rs @@ -134,7 +134,6 @@ impl Role { } pub fn register_role_listener(&self, listeners: &mut Listeners) { - #[allow(clippy::single_match)] match self { Role::Spy => listeners.add_listener(Box::new(SpyListener {role: Role::Spy})), Role::WolfAgent => listeners.add_listener(Box::new(SpyListener {role: Role::WolfAgent})), diff --git a/src/game/role/spy.rs b/src/game/role/spy.rs index 3d4d98d..e2c3549 100644 --- a/src/game/role/spy.rs +++ b/src/game/role/spy.rs @@ -15,6 +15,10 @@ pub struct SpyListener { #[async_trait] impl Listener for SpyListener { + fn name(&self) -> String { + format!("{} DM Listener", self.role) + } + fn get_priority(&self) -> Priority { Priority::Logging } @@ -56,6 +60,8 @@ impl Listener for SpyListener { // 1/4 chance to intercept message if thread_rng().gen_bool(0.25) { + println!("Sending a spy message..."); + let msg_content = MessageBuilder::default() .push_bold_line_safe(format!( "{} Sent {} a private message:", diff --git a/src/main.rs b/src/main.rs index cfe75a8..ca4ed76 100644 --- a/src/main.rs +++ b/src/main.rs @@ -35,6 +35,7 @@ async fn main() { let mut listeners = Listeners::default(); Role::Spy.register_role_listener(&mut listeners); + Role::WolfAgent.register_role_listener(&mut listeners); let mut client = Client::builder(&bot_cfg.discord_config.token, GatewayIntents::all()) .event_handler(Handler {})