tools/ubot/src/main.rs
changeset 15792 191e51179d1b
parent 15789 d97ea528ce95
child 15814 d9db7b763bd1
--- 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?;