summaryrefslogtreecommitdiff
path: root/src/irc/irc_client.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/irc/irc_client.cpp')
-rw-r--r--src/irc/irc_client.cpp32
1 files changed, 30 insertions, 2 deletions
diff --git a/src/irc/irc_client.cpp b/src/irc/irc_client.cpp
index 884f214..78acce5 100644
--- a/src/irc/irc_client.cpp
+++ b/src/irc/irc_client.cpp
@@ -59,6 +59,8 @@ void IrcClient::on_connection_close()
IrcChannel* IrcClient::get_channel(const std::string& name)
{
+ if (name.empty())
+ return &this->dummy_channel;
try
{
return this->channels.at(name).get();
@@ -195,7 +197,12 @@ void IrcClient::send_part_command(const std::string& chan_name, const std::strin
{
IrcChannel* channel = this->get_channel(chan_name);
if (channel->joined == true)
- this->send_message(IrcMessage("PART", {chan_name, status_message}));
+ {
+ if (chan_name.empty())
+ this->bridge->send_muc_leave(Iid(std::string("%") + this->hostname), std::string(this->current_nick), "", true);
+ else
+ this->send_message(IrcMessage("PART", {chan_name, status_message}));
+ }
}
void IrcClient::send_mode_command(const std::string& chan_name, const std::vector<std::string>& arguments)
@@ -280,7 +287,11 @@ void IrcClient::set_and_forward_user_list(const IrcMessage& message)
void IrcClient::on_channel_join(const IrcMessage& message)
{
const std::string chan_name = utils::tolower(message.arguments[0]);
- IrcChannel* channel = this->get_channel(chan_name);
+ IrcChannel* channel;
+ if (chan_name.empty())
+ channel = &this->dummy_channel;
+ else
+ channel = this->get_channel(chan_name);
const std::string nick = message.prefix;
if (channel->joined == false)
channel->set_self(nick);
@@ -394,6 +405,18 @@ void IrcClient::on_welcome_message(const IrcMessage& message)
for (const std::string& chan_name: this->channels_to_join)
this->send_join_command(chan_name);
this->channels_to_join.clear();
+ // Indicate that the dummy channel is joined as well, if needed
+ if (this->dummy_channel.joining)
+ {
+ // Simulate a message coming from the IRC server saying that we joined
+ // the channel
+ const IrcMessage join_message(this->get_nick(), "JOIN", {""});
+ this->on_channel_join(join_message);
+ const IrcMessage end_join_message(std::string(this->hostname), "366",
+ {this->get_nick(),
+ "", "End of NAMES list"});
+ this->on_channel_completely_joined(end_join_message);
+ }
}
void IrcClient::on_part(const IrcMessage& message)
@@ -624,3 +647,8 @@ size_t IrcClient::number_of_joined_channels() const
{
return this->channels.size();
}
+
+DummyIrcChannel& IrcClient::get_dummy_channel()
+{
+ return this->dummy_channel;
+}