From 04d28f968b227067e77e365d317fc251d3c965f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Tue, 19 Apr 2016 02:43:26 +0200 Subject: Forward the topic authors, handle the author from 333 messages fix #2 --- src/bridge/bridge.cpp | 5 +++-- src/bridge/bridge.hpp | 2 +- src/irc/irc_channel.hpp | 1 + src/irc/irc_client.cpp | 16 ++++++++++++++-- src/irc/irc_client.hpp | 4 ++++ 5 files changed, 23 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/bridge/bridge.cpp b/src/bridge/bridge.cpp index 4c97a91..2815da9 100644 --- a/src/bridge/bridge.cpp +++ b/src/bridge/bridge.cpp @@ -634,10 +634,11 @@ void Bridge::send_user_join(const std::string& hostname, affiliation, role, this->user_jid, self); } -void Bridge::send_topic(const std::string& hostname, const std::string& chan_name, const std::string& topic) +void Bridge::send_topic(const std::string& hostname, const std::string& chan_name, const std::string& topic, const std::string& who) { const auto encoding = in_encoding_for(*this, {chan_name + '%' + hostname}); - this->xmpp.send_topic(chan_name + utils::empty_if_fixed_server("%" + hostname), this->make_xmpp_body(topic, encoding), this->user_jid); + this->xmpp.send_topic(chan_name + utils::empty_if_fixed_server( + "%" + hostname), this->make_xmpp_body(topic, encoding), this->user_jid, who); } std::string Bridge::get_own_nick(const Iid& iid) diff --git a/src/bridge/bridge.hpp b/src/bridge/bridge.hpp index c030ed8..6222ef0 100644 --- a/src/bridge/bridge.hpp +++ b/src/bridge/bridge.hpp @@ -122,7 +122,7 @@ public: /** * Send the topic of the MUC to the user */ - void send_topic(const std::string& hostname, const std::string& chan_name, const std::string& topic); + void send_topic(const std::string& hostname, const std::string& chan_name, const std::string& topic, const std::string& who); /** * Send a MUC message from some participant */ 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_mapget_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 @@ -198,6 +198,10 @@ public: * Save the topic in the IrcChannel */ 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 */ -- cgit v1.2.3