diff options
author | Peter Powell <petpow@saberuk.com> | 2018-08-13 20:17:46 +0100 |
---|---|---|
committer | Peter Powell <petpow@saberuk.com> | 2018-08-13 21:51:11 +0100 |
commit | 58a0a7e01422e62de1565a8eb0a1febdc463d04d (patch) | |
tree | 8861789deefe9df3524690de8ccd11e5366f1f2e /src/modules/m_ircv3_echomessage.cpp | |
parent | e2a820cce21342478653a34cf8ce2b593128d035 (diff) |
Implement IRCv3 message tag support.
Co-authored-by: Attila Molnar <attilamolnar@hush.com>
Diffstat (limited to 'src/modules/m_ircv3_echomessage.cpp')
-rw-r--r-- | src/modules/m_ircv3_echomessage.cpp | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/modules/m_ircv3_echomessage.cpp b/src/modules/m_ircv3_echomessage.cpp index 056b02194..702552ea7 100644 --- a/src/modules/m_ircv3_echomessage.cpp +++ b/src/modules/m_ircv3_echomessage.cpp @@ -21,8 +21,6 @@ #include "inspircd.h" #include "modules/cap.h" -static const char* MessageTypeStringSp[] = { "PRIVMSG ", "NOTICE " }; - class ModuleIRCv3EchoMessage : public Module { Cap::Capability cap; @@ -38,27 +36,31 @@ class ModuleIRCv3EchoMessage : public Module if (!cap.get(user)) return; - std::string msg = MessageTypeStringSp[details.type]; + // Caps are only set on local users + LocalUser* const localuser = static_cast<LocalUser*>(user); + + const std::string& text = details.echooriginal ? details.originaltext : details.text; if (target.type == MessageTarget::TYPE_USER) { User* destuser = target.Get<User>(); - msg.append(destuser->nick); + ClientProtocol::Messages::Privmsg privmsg(ClientProtocol::Messages::Privmsg::nocopy, user, destuser, text, details.type); + privmsg.AddTags(details.tags_in); + localuser->Send(ServerInstance->GetRFCEvents().privmsg, privmsg); } else if (target.type == MessageTarget::TYPE_CHANNEL) { - if (target.status) - msg.push_back(target.status); - Channel* chan = target.Get<Channel>(); - msg.append(chan->name); + ClientProtocol::Messages::Privmsg privmsg(ClientProtocol::Messages::Privmsg::nocopy, user, chan, text, details.type, target.status); + privmsg.AddTags(details.tags_in); + localuser->Send(ServerInstance->GetRFCEvents().privmsg, privmsg); } else { const std::string* servername = target.Get<std::string>(); - msg.append(*servername); + ClientProtocol::Messages::Privmsg privmsg(ClientProtocol::Messages::Privmsg::nocopy, user, *servername, text, details.type); + privmsg.AddTags(details.tags_in); + localuser->Send(ServerInstance->GetRFCEvents().privmsg, privmsg); } - msg.append(" :").append(details.echooriginal ? details.originaltext : details.text); - user->WriteFrom(user, msg); } void OnUserMessageBlocked(User* user, const MessageTarget& target, const MessageDetails& details) CXX11_OVERRIDE |