diff --git a/config.toml b/config.toml index 1d0a95e..eddfef6 100644 --- a/config.toml +++ b/config.toml @@ -1,7 +1,7 @@ channels = ["#main", "#circe"] -host = "192.168.1.28" +host = "karx.xyz" mode = "+B" nickname = "circe" -port = 6667 +port = 6697 username = "circe" - +ssl = true diff --git a/src/lib.rs b/src/lib.rs index 5a8c395..b8f5d54 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -119,6 +119,7 @@ impl Client { self.write_command(commands::Command::PONG(code.to_string()))?; } commands::Command::OTHER(line) => { + #[cfg(feature = "debug")] println!("{}", line); if line.contains("001") { break; @@ -146,7 +147,11 @@ impl Client { Err(_) => return None, }; - Some(String::from_utf8_lossy(&buffer).into()) + let res = String::from_utf8_lossy(&buffer); + + // The trimming is required because if the message is less than 512 bytes it will be + // padded with a bunch of 0u8 because of the pre-allocated buffer + Some(res.trim().trim_matches(char::from(0)).trim().into()) } /// Read data coming from the IRC as a [`commands::Command`]. @@ -167,6 +172,9 @@ impl Client { /// Returns error if there are no new messages. This should not be taken as an actual error, because nothing went wrong. pub fn read(&mut self) -> Result { if let Some(string) = self.read_string() { + #[cfg(feature = "debug")] + println!("{:#?}", string); + let command = commands::Command::from_str(&string); if let commands::Command::PONG(command) = command {