feat: add multi lines support for CTCP
This commit is contained in:
parent
0f675e7c27
commit
4d0acf91a1
1 changed files with 7 additions and 3 deletions
|
@ -336,7 +336,11 @@ macro_rules! pub_sender_base {
|
||||||
S1: fmt::Display,
|
S1: fmt::Display,
|
||||||
S2: fmt::Display,
|
S2: fmt::Display,
|
||||||
{
|
{
|
||||||
self.send_privmsg(target, &format!("\u{001}{}\u{001}", msg.to_string())[..])
|
let msg = msg.to_string();
|
||||||
|
for line in msg.split("\r\n") {
|
||||||
|
self.send(PRIVMSG(target.to_string(), format!("\u{001}{}\u{001}", line)))?
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sends an action command to the specified target.
|
/// Sends an action command to the specified target.
|
||||||
|
@ -1842,11 +1846,11 @@ mod test {
|
||||||
#[cfg(feature = "ctcp")]
|
#[cfg(feature = "ctcp")]
|
||||||
async fn send_ctcp() -> Result<()> {
|
async fn send_ctcp() -> Result<()> {
|
||||||
let mut client = Client::from_config(test_config()).await?;
|
let mut client = Client::from_config(test_config()).await?;
|
||||||
client.send_ctcp("test", "MESSAGE")?;
|
client.send_ctcp("test", "LINE1\r\nLINE2\r\nLINE3")?;
|
||||||
client.stream()?.collect().await?;
|
client.stream()?.collect().await?;
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
&get_client_value(client)[..],
|
&get_client_value(client)[..],
|
||||||
"PRIVMSG test \u{001}MESSAGE\u{001}\r\n"
|
"PRIVMSG test \u{001}LINE1\u{001}\r\nPRIVMSG test \u{001}LINE2\u{001}\r\nPRIVMSG test \u{001}LINE3\u{001}\r\n"
|
||||||
);
|
);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue