浏览代码

IRCClient: Process incoming NOTICE messages like PRIVMSG.

They should be handled slightly differently, but at least now we're doing
*something* withthem.
Andreas Kling 6 年之前
父节点
当前提交
9a7b638743
共有 2 个文件被更改,包括 15 次插入4 次删除
  1. 9 3
      Applications/IRCClient/IRCClient.cpp
  2. 6 1
      Applications/IRCClient/IRCClient.h

+ 9 - 3
Applications/IRCClient/IRCClient.cpp

@@ -267,7 +267,10 @@ void IRCClient::handle(const Message& msg)
         return handle_topic(msg);
 
     if (msg.command == "PRIVMSG")
-        return handle_privmsg(msg);
+        return handle_privmsg_or_notice(msg, PrivmsgOrNotice::Privmsg);
+
+    if (msg.command == "NOTICE")
+        return handle_privmsg_or_notice(msg, PrivmsgOrNotice::Notice);
 
     if (msg.command == "NICK")
         return handle_nick(msg);
@@ -326,7 +329,7 @@ bool IRCClient::is_nick_prefix(char ch) const
     return false;
 }
 
-void IRCClient::handle_privmsg(const Message& msg)
+void IRCClient::handle_privmsg_or_notice(const Message& msg, PrivmsgOrNotice type)
 {
     if (msg.arguments.size() < 2)
         return;
@@ -337,7 +340,10 @@ void IRCClient::handle_privmsg(const Message& msg)
     auto target = msg.arguments[0];
 
 #ifdef IRC_DEBUG
-    printf("handle_privmsg: sender_nick='%s', target='%s'\n", sender_nick.characters(), target.characters());
+    printf("handle_privmsg_or_notice: type='%s', sender_nick='%s', target='%s'\n",
+        type == PrivmsgOrNotice::Privmsg ? "privmsg" : "notice",
+        sender_nick.characters(),
+        target.characters());
 #endif
 
     if (sender_nick.is_empty())

+ 6 - 1
Applications/IRCClient/IRCClient.h

@@ -87,6 +87,11 @@ private:
         Vector<String> arguments;
     };
 
+    enum class PrivmsgOrNotice {
+        Privmsg,
+        Notice,
+    };
+
     void receive_from_server();
     void send(const String&);
     void send_user();
@@ -109,7 +114,7 @@ private:
     void handle_rpl_topicwhotime(const Message&);
     void handle_rpl_endofnames(const Message&);
     void handle_rpl_namreply(const Message&);
-    void handle_privmsg(const Message&);
+    void handle_privmsg_or_notice(const Message&, PrivmsgOrNotice);
     void handle_nick(const Message&);
     void handle(const Message&);
     void handle_user_command(const String&);