tools/ubot/src/main.rs
changeset 15792 191e51179d1b
parent 15789 d97ea528ce95
child 15814 d9db7b763bd1
equal deleted inserted replaced
15791:2528e3508bf4 15792:191e51179d1b
    49             &target[1..]
    49             &target[1..]
    50         } else {
    50         } else {
    51             &target
    51             &target
    52         };
    52         };
    53 
    53 
       
    54         let who = irc_message.source_nickname().unwrap_or(msgtarget);
       
    55 
    54         if message.starts_with("!") {
    56         if message.starts_with("!") {
    55             if let Some((cmd, param)) = message.split_once(' ') {
    57             if let Some((cmd, param)) = message.split_once(' ') {
    56                 pub_channel
    58                 pub_channel
    57                     .basic_publish(
    59                     .basic_publish(
    58                         "irc",
    60                         "irc",
    59                         &format!("cmd.{}.{}", &cmd[1..], target),
    61                         &format!("cmd.{}.{}", &cmd[1..], target),
    60                         BasicPublishOptions::default(),
    62                         BasicPublishOptions::default(),
    61                         format!("{}\n{}", msgtarget, param).as_bytes().to_vec(),
    63                         format!("{}\n{}", who, param).as_bytes().to_vec(),
    62                         BasicProperties::default(),
    64                         BasicProperties::default(),
    63                     )
    65                     )
    64                     .await?;
    66                     .await?;
    65             } else {
    67             } else {
    66                 pub_channel
    68                 pub_channel
    67                     .basic_publish(
    69                     .basic_publish(
    68                         "irc",
    70                         "irc",
    69                         &format!("cmd.{}.{}", &message[1..], target),
    71                         &format!("cmd.{}.{}", &message[1..], target),
    70                         BasicPublishOptions::default(),
    72                         BasicPublishOptions::default(),
    71                         msgtarget.as_bytes().to_vec(),
    73                         who.as_bytes().to_vec(),
    72                         BasicProperties::default(),
    74                         BasicProperties::default(),
    73                     )
    75                     )
    74                     .await?;
    76                     .await?;
    75             }
    77             }
    76         } else {
    78         } else {
    77             pub_channel
    79             pub_channel
    78                 .basic_publish(
    80                 .basic_publish(
    79                     "irc",
    81                     "irc",
    80                     &format!("msg.{}", target),
    82                     &format!("msg.{}", target),
    81                     BasicPublishOptions::default(),
    83                     BasicPublishOptions::default(),
    82                     format!("{}\n{}", msgtarget, message).as_bytes().to_vec(),
    84                     format!("{}\n{}", who, message).as_bytes().to_vec(),
    83                     BasicProperties::default(),
    85                     BasicProperties::default(),
    84                 )
    86                 )
    85                 .await?;
    87                 .await?;
    86         }
    88         }
    87     }
    89     }