diff options
Diffstat (limited to 'src/irc')
-rw-r--r-- | src/irc/iid.cpp | 3 | ||||
-rw-r--r-- | src/irc/irc_client.cpp | 33 |
2 files changed, 21 insertions, 15 deletions
diff --git a/src/irc/iid.cpp b/src/irc/iid.cpp index a63a1c3..131c18c 100644 --- a/src/irc/iid.cpp +++ b/src/irc/iid.cpp @@ -35,7 +35,8 @@ Iid::Iid(const std::string& iid, const Bridge *bridge) void Iid::set_type(const std::set<char>& chantypes) { - if (this->local.empty() && this->server.empty()) + if (this->local.empty() && ( + !Config::get("fixed_irc_server", "").empty() || this->server.empty())) this->type = Iid::Type::None; if (this->local.empty()) return; diff --git a/src/irc/irc_client.cpp b/src/irc/irc_client.cpp index bacb89e..46dbdbe 100644 --- a/src/irc/irc_client.cpp +++ b/src/irc/irc_client.cpp @@ -178,7 +178,7 @@ IrcClient::~IrcClient() { // This event may or may not exist (if we never got connected, it // doesn't), but it's ok - TimedEventsManager::instance().cancel("PING"s + this->hostname + this->bridge.get_jid()); + TimedEventsManager::instance().cancel("PING" + this->hostname + this->bridge.get_jid()); } void IrcClient::start() @@ -194,7 +194,7 @@ void IrcClient::start() bool tls; std::tie(port, tls) = this->ports_to_try.top(); this->ports_to_try.pop(); - this->bridge.send_xmpp_message(this->hostname, "", "Connecting to "s + + this->bridge.send_xmpp_message(this->hostname, "", "Connecting to " + this->hostname + ":" + port + " (" + (tls ? "encrypted" : "not encrypted") + ")"); @@ -213,7 +213,7 @@ void IrcClient::start() void IrcClient::on_connection_failed(const std::string& reason) { this->bridge.send_xmpp_message(this->hostname, "", - "Connection failed: "s + reason); + "Connection failed: " + reason); if (this->hostname_resolution_failed) while (!this->ports_to_try.empty()) @@ -260,7 +260,7 @@ void IrcClient::on_connected() { if (this->is_connected()) { - this->on_connection_close("Could not resolve hostname "s + this->user_hostname + + this->on_connection_close("Could not resolve hostname " + this->user_hostname + ": " + error_msg); this->send_quit_command(""); } @@ -297,6 +297,7 @@ void IrcClient::on_connected() #endif this->send_gateway_message("Connected to IRC server"s + (this->use_tls ? " (encrypted)": "") + "."); this->send_pending_data(); + this->bridge.on_irc_client_connected(this->get_hostname()); } void IrcClient::on_connection_close(const std::string& error_msg) @@ -309,6 +310,7 @@ void IrcClient::on_connection_close(const std::string& error_msg) const IrcMessage error{"ERROR", {message}}; this->on_error(error); log_warning(message); + this->bridge.on_irc_client_disconnected(this->get_hostname()); } IrcChannel* IrcClient::get_channel(const std::string& n) @@ -585,7 +587,7 @@ void IrcClient::on_notice(const IrcMessage& message) // The notice was directed at a channel we are in. Modify the message // to indicate that it is a notice, and make it a MUC message coming // from the MUC JID - IrcMessage modified_message(std::move(from), "PRIVMSG", {to, "\u000303[notice]\u0003 "s + body}); + IrcMessage modified_message(std::move(from), "PRIVMSG", {to, "\u000303[notice]\u0003 " + body}); this->on_channel_message(modified_message); } } @@ -697,7 +699,7 @@ void IrcClient::on_channel_message(const IrcMessage& message) { if (body.substr(1, 6) == "ACTION") this->bridge.send_message(iid, nick, - "/me"s + body.substr(7, body.size() - 8), muc); + "/me" + body.substr(7, body.size() - 8), muc); else if (body.substr(1, 8) == "VERSION\01") this->bridge.send_iq_version_request(nick, this->hostname); else if (body.substr(1, 5) == "PING ") @@ -899,7 +901,7 @@ void IrcClient::on_welcome_message(const IrcMessage& message) #endif // Install a repeated events to regularly send a PING TimedEventsManager::instance().add_event(TimedEvent(240s, std::bind(&IrcClient::send_ping_command, this), - "PING"s + this->hostname + this->bridge.get_jid())); + "PING" + this->hostname + this->bridge.get_jid())); std::string channels{}; std::string channels_with_key{}; std::string keys{}; @@ -981,7 +983,7 @@ void IrcClient::on_part(const IrcMessage& message) // channel pointer is now invalid channel = nullptr; } - this->bridge.send_muc_leave(iid, std::move(nick), txt, self); + this->bridge.send_muc_leave(iid, std::move(nick), txt, self, true); } } @@ -999,10 +1001,10 @@ void IrcClient::on_error(const IrcMessage& message) if (!channel->joined) continue; std::string own_nick = channel->get_self()->nick; - this->bridge.send_muc_leave(iid, std::move(own_nick), leave_message, true); + this->bridge.send_muc_leave(iid, std::move(own_nick), leave_message, true, false); } this->channels.clear(); - this->send_gateway_message("ERROR: "s + leave_message); + this->send_gateway_message("ERROR: " + leave_message); } void IrcClient::on_quit(const IrcMessage& message) @@ -1015,6 +1017,9 @@ void IrcClient::on_quit(const IrcMessage& message) const std::string& chan_name = pair.first; IrcChannel* channel = pair.second.get(); const IrcUser* user = channel->find_user(message.prefix); + bool self = false; + if (user == channel->get_self()) + self = true; if (user) { std::string nick = user->nick; @@ -1023,7 +1028,7 @@ void IrcClient::on_quit(const IrcMessage& message) iid.set_local(chan_name); iid.set_server(this->hostname); iid.type = Iid::Type::Channel; - this->bridge.send_muc_leave(iid, std::move(nick), txt, false); + this->bridge.send_muc_leave(iid, std::move(nick), txt, self, false); } } } @@ -1135,7 +1140,7 @@ void IrcClient::on_channel_mode(const IrcMessage& message) mode_arguments += message.arguments[i]; } } - this->bridge.send_message(iid, "", "Mode "s + iid.get_local() + + this->bridge.send_message(iid, "", "Mode " + iid.get_local() + " [" + mode_arguments + "] by " + user.nick, true); const IrcChannel* channel = this->get_channel(iid.get_local()); @@ -1213,7 +1218,7 @@ void IrcClient::on_channel_mode(const IrcMessage& message) void IrcClient::on_user_mode(const IrcMessage& message) { this->bridge.send_xmpp_message(this->hostname, "", - "User mode for "s + message.arguments[0] + + "User mode for " + message.arguments[0] + " is [" + message.arguments[1] + "]"); } @@ -1252,7 +1257,7 @@ void IrcClient::leave_dummy_channel(const std::string& exit_message, const std:: this->dummy_channel.joined = false; this->dummy_channel.joining = false; this->dummy_channel.remove_all_users(); - this->bridge.send_muc_leave(Iid("%"s + this->hostname, this->chantypes), std::string(this->current_nick), exit_message, true, resource); + this->bridge.send_muc_leave(Iid("%" + this->hostname, this->chantypes), std::string(this->current_nick), exit_message, true, true, resource); } #ifdef BOTAN_FOUND |