Jelajahi Sumber

darkirc/irc/client: handle message lines if present

skoupidi 1 tahun lalu
induk
melakukan
e675f3a775
1 mengubah file dengan 15 tambahan dan 7 penghapusan
  1. 15 7
      bin/darkirc/src/irc/client.rs

+ 15 - 7
bin/darkirc/src/irc/client.rs

@@ -261,14 +261,22 @@ impl Client {
                         }
                         }
                         drop(chans_lock);
                         drop(chans_lock);
 
 
-                        // Format the message
-                        let msg = format!("PRIVMSG {} :{}", privmsg.channel, privmsg.msg);
+                        // Handle message lines individually
+                        for line in privmsg.msg.lines() {
+                            // Skip empty lines
+                            if line.is_empty() {
+                                continue
+                            }
 
 
-                        // Send it to the client
-                        let reply = ReplyType::Client((privmsg.nick, msg));
-                        if let Err(e) = self.reply(&mut writer, &reply).await {
-                            error!("[IRC CLIENT] Failed writing PRIVMSG to client: {}", e);
-                            continue
+                            // Format the message
+                            let msg = format!("PRIVMSG {} :{}", privmsg.channel, line);
+
+                            // Send it to the client
+                            let reply = ReplyType::Client((privmsg.nick.clone(), msg));
+                            if let Err(e) = self.reply(&mut writer, &reply).await {
+                                error!("[IRC CLIENT] Failed writing PRIVMSG to client: {}", e);
+                                continue
+                            }
                         }
                         }
 
 
                         // Mark the message as seen for this USER
                         // Mark the message as seen for this USER