Fix detection of message author in ubot core
authorunc0rr
Tue, 15 Jun 2021 20:45:46 +0200
changeset 15792 191e51179d1b
parent 15791 2528e3508bf4
child 15793 96443d9b48c9
Fix detection of message author in ubot core
tools/ubot/src/main.rs
--- a/tools/ubot/src/main.rs	Sat Jun 12 20:58:07 2021 +0200
+++ b/tools/ubot/src/main.rs	Tue Jun 15 20:45:46 2021 +0200
@@ -51,6 +51,8 @@
             &target
         };
 
+        let who = irc_message.source_nickname().unwrap_or(msgtarget);
+
         if message.starts_with("!") {
             if let Some((cmd, param)) = message.split_once(' ') {
                 pub_channel
@@ -58,7 +60,7 @@
                         "irc",
                         &format!("cmd.{}.{}", &cmd[1..], target),
                         BasicPublishOptions::default(),
-                        format!("{}\n{}", msgtarget, param).as_bytes().to_vec(),
+                        format!("{}\n{}", who, param).as_bytes().to_vec(),
                         BasicProperties::default(),
                     )
                     .await?;
@@ -68,7 +70,7 @@
                         "irc",
                         &format!("cmd.{}.{}", &message[1..], target),
                         BasicPublishOptions::default(),
-                        msgtarget.as_bytes().to_vec(),
+                        who.as_bytes().to_vec(),
                         BasicProperties::default(),
                     )
                     .await?;
@@ -79,7 +81,7 @@
                     "irc",
                     &format!("msg.{}", target),
                     BasicPublishOptions::default(),
-                    format!("{}\n{}", msgtarget, message).as_bytes().to_vec(),
+                    format!("{}\n{}", who, message).as_bytes().to_vec(),
                     BasicProperties::default(),
                 )
                 .await?;