فهرست منبع

IRCClient: Allow CTCP replies to be user configurable in IRCClient.ini

Brendan Coles 5 سال پیش
والد
کامیت
ddb8597c0c
3فایلهای تغییر یافته به همراه36 افزوده شده و 1 حذف شده
  1. 23 1
      Applications/IRCClient/IRCClient.cpp
  2. 8 0
      Applications/IRCClient/IRCClient.h
  3. 5 0
      Base/home/anon/IRCClient.ini

+ 23 - 1
Applications/IRCClient/IRCClient.cpp

@@ -75,6 +75,9 @@ IRCClient::IRCClient()
     m_nickname = m_config->read_entry("User", "Nickname", "seren1ty");
     m_hostname = m_config->read_entry("Connection", "Server", "");
     m_port = m_config->read_num_entry("Connection", "Port", 6667);
+    m_ctcp_version_reply = m_config->read_entry("CTCP", "VersionReply", "IRC Client [x86] / Serenity OS");
+    m_ctcp_userinfo_reply = m_config->read_entry("CTCP", "UserInfoReply", "anon");
+    m_ctcp_finger_reply = m_config->read_entry("CTCP", "FingerReply", "anon");
 }
 
 IRCClient::~IRCClient()
@@ -1056,7 +1059,26 @@ void IRCClient::handle_ctcp_request(const StringView& peer, const StringView& pa
     dbg() << "handle_ctcp_request: " << payload;
 
     if (payload == "VERSION") {
-        send_ctcp_response(peer, "VERSION IRC Client [x86] / Serenity OS");
+        auto version = ctcp_version_reply();
+        if (version.is_empty())
+            return;
+        send_ctcp_response(peer, String::format("VERSION %s", version.characters()));
+        return;
+    }
+
+    if (payload == "USERINFO") {
+        auto userinfo = ctcp_userinfo_reply();
+        if (userinfo.is_empty())
+            return;
+        send_ctcp_response(peer, String::format("USERINFO %s", userinfo.characters()));
+        return;
+    }
+
+    if (payload == "FINGER") {
+        auto finger = ctcp_finger_reply();
+        if (finger.is_empty())
+            return;
+        send_ctcp_response(peer, String::format("FINGER %s", finger.characters()));
         return;
     }
 

+ 8 - 0
Applications/IRCClient/IRCClient.h

@@ -56,6 +56,10 @@ public:
 
     String nickname() const { return m_nickname; }
 
+    String ctcp_version_reply() const { return m_ctcp_version_reply; }
+    String ctcp_userinfo_reply() const { return m_ctcp_userinfo_reply; }
+    String ctcp_finger_reply() const { return m_ctcp_finger_reply; }
+
     void join_channel(const String&);
     void part_channel(const String&);
     void change_nick(const String&);
@@ -198,6 +202,10 @@ private:
     HashMap<String, RefPtr<IRCChannel>, CaseInsensitiveStringTraits> m_channels;
     HashMap<String, RefPtr<IRCQuery>, CaseInsensitiveStringTraits> m_queries;
 
+    String m_ctcp_version_reply;
+    String m_ctcp_userinfo_reply;
+    String m_ctcp_finger_reply;
+
     Vector<IRCWindow*> m_windows;
 
     IRCWindow* m_server_subwindow { nullptr };

+ 5 - 0
Base/home/anon/IRCClient.ini

@@ -5,3 +5,8 @@ Nickname=anon_seren1ty
 Server=chat.freenode.net
 Port=6667
 AutoJoinChannels=#serenityos
+
+[CTCP]
+VersionReply=IRC Client [x86] / Serenity OS
+UserInfoReply=anon
+FingerReply=anon