diff options
author | louiz’ <louiz@louiz.org> | 2016-04-19 02:43:26 +0200 |
---|---|---|
committer | louiz’ <louiz@louiz.org> | 2016-04-22 10:49:07 +0200 |
commit | 04d28f968b227067e77e365d317fc251d3c965f7 (patch) | |
tree | f457b9167c1d91312a8ce341abe0559be2877be7 /src/irc | |
parent | 64f341ee80b0d53f0a6e128a1ccc38205361c3bb (diff) | |
download | biboumi-04d28f968b227067e77e365d317fc251d3c965f7.tar.gz biboumi-04d28f968b227067e77e365d317fc251d3c965f7.tar.bz2 biboumi-04d28f968b227067e77e365d317fc251d3c965f7.tar.xz biboumi-04d28f968b227067e77e365d317fc251d3c965f7.zip |
Forward the topic authors, handle the author from 333 messages
fix #2
Diffstat (limited to 'src/irc')
-rw-r--r-- | src/irc/irc_channel.hpp | 1 | ||||
-rw-r--r-- | src/irc/irc_client.cpp | 16 | ||||
-rw-r--r-- | src/irc/irc_client.hpp | 4 |
3 files changed, 19 insertions, 2 deletions
diff --git a/src/irc/irc_channel.hpp b/src/irc/irc_channel.hpp index 568de0a..651b8ed 100644 --- a/src/irc/irc_channel.hpp +++ b/src/irc/irc_channel.hpp @@ -18,6 +18,7 @@ public: bool joined; std::string topic; + std::string topic_author; void set_self(const std::string& name); IrcUser* get_self() const; IrcUser* add_user(const std::string& name, diff --git a/src/irc/irc_client.cpp b/src/irc/irc_client.cpp index 1150155..327b170 100644 --- a/src/irc/irc_client.cpp +++ b/src/irc/irc_client.cpp @@ -55,6 +55,8 @@ static const std::unordered_map<std::string, {"353", {&IrcClient::set_and_forward_user_list, {4, 0}}}, {"332", {&IrcClient::on_topic_received, {2, 0}}}, {"TOPIC", {&IrcClient::on_topic_received, {2, 0}}}, + {"333", {&IrcClient::on_topic_who_time_received, {4, 0}}}, + {"RPL_TOPICWHOTIME", {&IrcClient::on_topic_who_time_received, {4, 0}}}, {"366", {&IrcClient::on_channel_completely_joined, {2, 0}}}, {"432", {&IrcClient::on_erroneous_nickname, {2, 0}}}, {"433", {&IrcClient::on_nickname_conflict, {2, 0}}}, @@ -723,10 +725,20 @@ void IrcClient::send_motd(const IrcMessage&) void IrcClient::on_topic_received(const IrcMessage& message) { const std::string chan_name = utils::tolower(message.arguments[message.arguments.size() - 2]); + IrcUser author(message.prefix); IrcChannel* channel = this->get_channel(chan_name); channel->topic = message.arguments[message.arguments.size() - 1]; + channel->topic_author = author.nick; if (channel->joined) - this->bridge.send_topic(this->hostname, chan_name, channel->topic); + this->bridge.send_topic(this->hostname, chan_name, channel->topic, channel->topic_author); +} + +void IrcClient::on_topic_who_time_received(const IrcMessage& message) +{ + IrcUser author(message.arguments[2]); + const std::string chan_name = utils::tolower(message.arguments[1]); + IrcChannel* channel = this->get_channel(chan_name); + channel->topic_author = author.nick; } void IrcClient::on_channel_completely_joined(const IrcMessage& message) @@ -737,7 +749,7 @@ void IrcClient::on_channel_completely_joined(const IrcMessage& message) 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); + this->bridge.send_topic(this->hostname, chan_name, channel->topic, channel->topic_author); } void IrcClient::on_erroneous_nickname(const IrcMessage& message) diff --git a/src/irc/irc_client.hpp b/src/irc/irc_client.hpp index 5efecc6..ceaa860 100644 --- a/src/irc/irc_client.hpp +++ b/src/irc/irc_client.hpp @@ -199,6 +199,10 @@ public: */ void on_topic_received(const IrcMessage& message); /** + * Save the topic author in the IrcChannel + */ + void on_topic_who_time_received(const IrcMessage& message); + /** * Empty the topic */ void on_empty_topic(const IrcMessage& message); |