Merge pull request #208 from tirz/feature-ctcp_multi_lines
feat: add multi lines support for CTCP
This commit is contained in:
commit
99591ffeb0
1 changed files with 7 additions and 3 deletions
|
@ -336,7 +336,11 @@ macro_rules! pub_sender_base {
|
|||
S1: 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.
|
||||
|
@ -1842,11 +1846,11 @@ mod test {
|
|||
#[cfg(feature = "ctcp")]
|
||||
async fn send_ctcp() -> Result<()> {
|
||||
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?;
|
||||
assert_eq!(
|
||||
&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(())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue