fix some crashes

This commit is contained in:
sad 2024-03-15 02:02:03 -06:00
parent c70eda96b8
commit 5287b54864
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG Key ID: 28D3A882F3E6AD02
1 changed files with 6 additions and 2 deletions

View File

@ -225,12 +225,16 @@ async fn writemsg(mut writer: tokio::io::WriteHalf<tokio_native_tls::TlsStream<T
}
}
if *cmd == "PRIVMSG" {
let channel = parts[2];
let channel = &parts.get(2).to_owned().unwrap_or(&"");
let user = parts[0].strip_prefix(':')
.and_then(|user_with_host| user_with_host.split('!').next())
.unwrap_or("unknown_user");
let host = parts[0].split('@').nth(1).unwrap_or("unknown_host");
let msg_content = parts[3..].join(" ").replace(':', "");
let msg_content = if parts.len() > 3 {
parts[3..].join(" ").replace(':', "")
} else {
"".to_string()
};
println!("{} {} {} {} {} {} {} {} {}", "DEBUG:".bold().yellow(), "channel:".bold().green(), channel.purple(), "user:".bold().green(), user.purple(), "host:".bold().green(), host.purple(), "msg:".bold().green(), msg_content.yellow());
// sed