diff options
Diffstat (limited to 'src/irc')
-rw-r--r-- | src/irc/iid.cpp | 5 | ||||
-rw-r--r-- | src/irc/iid.hpp | 2 | ||||
-rw-r--r-- | src/irc/irc_channel.cpp | 15 | ||||
-rw-r--r-- | src/irc/irc_client.cpp | 12 | ||||
-rw-r--r-- | src/irc/irc_client.hpp | 2 |
5 files changed, 18 insertions, 18 deletions
diff --git a/src/irc/iid.cpp b/src/irc/iid.cpp index 212fb8f..66b66b7 100644 --- a/src/irc/iid.cpp +++ b/src/irc/iid.cpp @@ -100,3 +100,8 @@ namespace std { } } } + +std::tuple<std::string, std::string> Iid::to_tuple() const +{ + return std::make_tuple(this->get_local(), this->get_server()); +} diff --git a/src/irc/iid.hpp b/src/irc/iid.hpp index 1c026e8..9747595 100644 --- a/src/irc/iid.hpp +++ b/src/irc/iid.hpp @@ -60,6 +60,8 @@ public: std::string get_sep() const; + std::tuple<std::string, std::string> to_tuple() const; + private: void init(const std::string& iid); diff --git a/src/irc/irc_channel.cpp b/src/irc/irc_channel.cpp index b1b3983..9801513 100644 --- a/src/irc/irc_channel.cpp +++ b/src/irc/irc_channel.cpp @@ -1,4 +1,5 @@ #include <irc/irc_channel.hpp> +#include <algorithm> IrcChannel::IrcChannel(): joined(false), @@ -36,15 +37,11 @@ IrcUser* IrcChannel::find_user(const std::string& name) const void IrcChannel::remove_user(const IrcUser* user) { - for (auto it = this->users.begin(); it != this->users.end(); ++it) - { - IrcUser* u = it->get(); - if (u->nick == user->nick) - { - this->users.erase(it); - break ; - } - } + this->users.erase(std::remove_if(this->users.begin(), this->users.end(), + [user](const std::unique_ptr<IrcUser>& u) + { + return user->nick == u->nick; + }), this->users.end()); } void IrcChannel::remove_all_users() diff --git a/src/irc/irc_client.cpp b/src/irc/irc_client.cpp index ae68528..d16ffc7 100644 --- a/src/irc/irc_client.cpp +++ b/src/irc/irc_client.cpp @@ -618,9 +618,7 @@ void IrcClient::set_and_forward_user_list(const IrcMessage& message) const IrcUser* user = channel->add_user(nick, this->prefix_to_mode); if (user->nick != channel->get_self()->nick) { - this->bridge.send_user_join(this->hostname, chan_name, user, - user->get_most_significant_mode(this->sorted_user_modes), - false); + this->bridge.send_user_join(this->hostname, chan_name, user, user->get_most_significant_mode(this->sorted_user_modes), false); } else { @@ -644,9 +642,7 @@ void IrcClient::on_channel_join(const IrcMessage& message) else { const IrcUser* user = channel->add_user(nick, this->prefix_to_mode); - this->bridge.send_user_join(this->hostname, chan_name, user, - user->get_most_significant_mode(this->sorted_user_modes), - false); + this->bridge.send_user_join(this->hostname, chan_name, user, user->get_most_significant_mode(this->sorted_user_modes), false); } } @@ -746,9 +742,7 @@ void IrcClient::on_channel_completely_joined(const IrcMessage& message) const std::string chan_name = utils::tolower(message.arguments[1]); IrcChannel* channel = this->get_channel(chan_name); channel->joined = true; - this->bridge.send_user_join(this->hostname, chan_name, channel->get_self(), - channel->get_self()->get_most_significant_mode(this->sorted_user_modes), - true); + this->bridge.send_user_join(this->hostname, chan_name, channel->get_self(), channel->get_self()->get_most_significant_mode(this->sorted_user_modes), true); this->bridge.send_topic(this->hostname, chan_name, channel->topic, channel->topic_author); } diff --git a/src/irc/irc_client.hpp b/src/irc/irc_client.hpp index 7af097c..f075ce6 100644 --- a/src/irc/irc_client.hpp +++ b/src/irc/irc_client.hpp @@ -276,6 +276,8 @@ public: const Resolver& get_resolver() const { return this->dns_resolver; } + const std::vector<char>& get_sorted_user_modes() const { return sorted_user_modes; } + private: /** * The hostname of the server we are connected to. |