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

This commit is contained in:
Brendan Coles 2020-04-05 12:32:08 +00:00 committed by Andreas Kling
parent bc40908d32
commit ddb8597c0c
Notes: sideshowbarker 2024-07-19 07:53:56 +09:00
3 changed files with 36 additions and 1 deletions

View File

@ -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;
}

View File

@ -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 };

View File

@ -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