Compare commits
No commits in common. "ed896d4e83e090bc05a0cffe71e2eadc245965cf" and "78912ca72fbc15ca53be229adf91cc6626b050d3" have entirely different histories.
ed896d4e83
...
78912ca72f
1 changed files with 3 additions and 19 deletions
|
|
@ -139,12 +139,7 @@ impl AsyncWriter for TlsWriter {
|
||||||
line: &str,
|
line: &str,
|
||||||
) -> std::pin::Pin<Box<dyn std::future::Future<Output = io::Result<()>> + '_>> {
|
) -> std::pin::Pin<Box<dyn std::future::Future<Output = io::Result<()>> + '_>> {
|
||||||
let data = format!("{line}\r\n");
|
let data = format!("{line}\r\n");
|
||||||
Box::pin(async move {
|
Box::pin(async move { self.inner.write_all(data.as_bytes()).await })
|
||||||
self.inner.write_all(data.as_bytes()).await?;
|
|
||||||
// Unconfirmed reports that some servers require
|
|
||||||
// multiple lines to be in separate packets
|
|
||||||
self.inner.flush().await
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -158,12 +153,7 @@ impl AsyncWriter for PlainWriter {
|
||||||
line: &str,
|
line: &str,
|
||||||
) -> std::pin::Pin<Box<dyn std::future::Future<Output = io::Result<()>> + '_>> {
|
) -> std::pin::Pin<Box<dyn std::future::Future<Output = io::Result<()>> + '_>> {
|
||||||
let data = format!("{line}\r\n");
|
let data = format!("{line}\r\n");
|
||||||
Box::pin(async move {
|
Box::pin(async move { self.inner.write_all(data.as_bytes()).await })
|
||||||
self.inner.write_all(data.as_bytes()).await?;
|
|
||||||
// Unconfirmed reports that some servers require
|
|
||||||
// multiple lines to be in separate packets
|
|
||||||
self.inner.flush().await
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -235,8 +225,6 @@ impl State {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn send_privmsg(&mut self, target: &str, msg: &str) -> io::Result<()> {
|
async fn send_privmsg(&mut self, target: &str, msg: &str) -> io::Result<()> {
|
||||||
// Send PRIVMSG, which is used for both private and channel messages.
|
|
||||||
// Splits into multiple fragments if necessary.
|
|
||||||
// IRC max line = 512 bytes including CRLF. The server prepends
|
// IRC max line = 512 bytes including CRLF. The server prepends
|
||||||
// our prefix when relaying: ":nick!~user@host PRIVMSG target :msg\r\n"
|
// our prefix when relaying: ":nick!~user@host PRIVMSG target :msg\r\n"
|
||||||
// User is often ~nick (nick_len + 1). Host is up to 63 bytes.
|
// User is often ~nick (nick_len + 1). Host is up to 63 bytes.
|
||||||
|
|
@ -258,11 +246,7 @@ impl State {
|
||||||
// Find last char boundary at or before max_msg
|
// Find last char boundary at or before max_msg
|
||||||
let mut i = max_msg;
|
let mut i = max_msg;
|
||||||
while i > 0 && !remaining.is_char_boundary(i) { i -= 1; }
|
while i > 0 && !remaining.is_char_boundary(i) { i -= 1; }
|
||||||
// To avoid splitting mid-word, see if there was a space recently
|
if i == 0 { max_msg } else { i }
|
||||||
let mut j = i;
|
|
||||||
while j > 0 && j > i-10 && remaining.as_bytes()[j] != b' ' { j -= 1; }
|
|
||||||
if remaining.as_bytes()[j] == b' ' { j }
|
|
||||||
else if i == 0 { max_msg } else { i }
|
|
||||||
};
|
};
|
||||||
let (chunk, rest) = remaining.split_at(split_at);
|
let (chunk, rest) = remaining.split_at(split_at);
|
||||||
self.send_raw(&format!("PRIVMSG {target} :{chunk}")).await?;
|
self.send_raw(&format!("PRIVMSG {target} :{chunk}")).await?;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue