mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:37:35 +00:00
IRCClient: Autojoin channels after client registration
Wait for the server to advise negotiation was successful (RPL_WELCOME) before autojoining channels. Fixes #1713
This commit is contained in:
parent
cd84544706
commit
68c7ca7d3b
2 changed files with 22 additions and 8 deletions
|
@ -46,6 +46,7 @@
|
||||||
#define IRC_DEBUG
|
#define IRC_DEBUG
|
||||||
|
|
||||||
enum IRCNumeric {
|
enum IRCNumeric {
|
||||||
|
RPL_WELCOME = 1,
|
||||||
RPL_WHOISUSER = 311,
|
RPL_WHOISUSER = 311,
|
||||||
RPL_WHOISSERVER = 312,
|
RPL_WHOISSERVER = 312,
|
||||||
RPL_WHOISOPERATOR = 313,
|
RPL_WHOISOPERATOR = 313,
|
||||||
|
@ -102,14 +103,6 @@ void IRCClient::on_socket_connected()
|
||||||
|
|
||||||
send_user();
|
send_user();
|
||||||
send_nick();
|
send_nick();
|
||||||
|
|
||||||
auto channel_str = m_config->read_entry("Connection", "AutoJoinChannels", "#test");
|
|
||||||
dbgprintf("IRCClient: Channels to autojoin: %s\n", channel_str.characters());
|
|
||||||
auto channels = channel_str.split(',');
|
|
||||||
for (auto& channel : channels) {
|
|
||||||
join_channel(channel);
|
|
||||||
dbgprintf("IRCClient: Auto joining channel: %s\n", channel.characters());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IRCClient::connect()
|
bool IRCClient::connect()
|
||||||
|
@ -271,6 +264,8 @@ void IRCClient::handle(const Message& msg)
|
||||||
|
|
||||||
if (is_numeric) {
|
if (is_numeric) {
|
||||||
switch (numeric) {
|
switch (numeric) {
|
||||||
|
case RPL_WELCOME:
|
||||||
|
return handle_rpl_welcome(msg);
|
||||||
case RPL_WHOISCHANNELS:
|
case RPL_WHOISCHANNELS:
|
||||||
return handle_rpl_whoischannels(msg);
|
return handle_rpl_whoischannels(msg);
|
||||||
case RPL_ENDOFWHO:
|
case RPL_ENDOFWHO:
|
||||||
|
@ -645,6 +640,24 @@ void IRCClient::handle_topic(const Message& msg)
|
||||||
ensure_channel(channel_name).handle_topic(nick, msg.arguments[1]);
|
ensure_channel(channel_name).handle_topic(nick, msg.arguments[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IRCClient::handle_rpl_welcome(const Message& msg)
|
||||||
|
{
|
||||||
|
if (msg.arguments.size() < 2)
|
||||||
|
return;
|
||||||
|
auto& welcome_message = msg.arguments[1];
|
||||||
|
add_server_message(String::format("%s", welcome_message.characters()));
|
||||||
|
|
||||||
|
auto channel_str = m_config->read_entry("Connection", "AutoJoinChannels", "");
|
||||||
|
if (channel_str.is_empty())
|
||||||
|
return;
|
||||||
|
dbgprintf("IRCClient: Channels to autojoin: %s\n", channel_str.characters());
|
||||||
|
auto channels = channel_str.split(',');
|
||||||
|
for (auto& channel : channels) {
|
||||||
|
join_channel(channel);
|
||||||
|
dbgprintf("IRCClient: Auto joining channel: %s\n", channel.characters());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void IRCClient::handle_rpl_topic(const Message& msg)
|
void IRCClient::handle_rpl_topic(const Message& msg)
|
||||||
{
|
{
|
||||||
if (msg.arguments.size() < 3)
|
if (msg.arguments.size() < 3)
|
||||||
|
|
|
@ -169,6 +169,7 @@ private:
|
||||||
void handle_quit(const Message&);
|
void handle_quit(const Message&);
|
||||||
void handle_ping(const Message&);
|
void handle_ping(const Message&);
|
||||||
void handle_topic(const Message&);
|
void handle_topic(const Message&);
|
||||||
|
void handle_rpl_welcome(const Message&);
|
||||||
void handle_rpl_topic(const Message&);
|
void handle_rpl_topic(const Message&);
|
||||||
void handle_rpl_whoisuser(const Message&);
|
void handle_rpl_whoisuser(const Message&);
|
||||||
void handle_rpl_whoisserver(const Message&);
|
void handle_rpl_whoisserver(const Message&);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue