Просмотр исходного кода

darkirc/irc/client: handle message lines if present

skoupidi 1 год назад
Родитель
Сommit
e675f3a775
1 измененных файлов с 15 добавлено и 7 удалено
  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);
 
-                        // 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