diff options
author | Peter Powell <petpow@saberuk.com> | 2017-12-11 19:42:52 +0000 |
---|---|---|
committer | Peter Powell <petpow@saberuk.com> | 2018-01-06 14:18:21 +0000 |
commit | 2fcb5ff4389a9a82d253acdff02a388ddcf14653 (patch) | |
tree | 96feee81599adb7ef02bc35293daccba7071a6de /src/modules/m_delayjoin.cpp | |
parent | 40514d0ba8279309f350a47652fffef745662926 (diff) |
Rework message handling.
- Move all message-related types to their own header to make moving
them to a cross-module events easier.
- Rename OnUserMessage to OnUserPostMessage.
- Rename OnText to OnUserMessage.
- Replace the dest, target_type, and status parameters with the
MessageTarget class.
- Replace the text, exempt_list, and msgtype parameters with the
MessageDetails struct.
- Add echooriginal and originaltext to the MessageDetails struct
to allow spam filtering to not be broken by cap echo-message.
Diffstat (limited to 'src/modules/m_delayjoin.cpp')
-rw-r--r-- | src/modules/m_delayjoin.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/modules/m_delayjoin.cpp b/src/modules/m_delayjoin.cpp index d26a56568..f9cd837d7 100644 --- a/src/modules/m_delayjoin.cpp +++ b/src/modules/m_delayjoin.cpp @@ -24,7 +24,6 @@ class DelayJoinMode : public ModeHandler { - CUList empty; public: DelayJoinMode(Module* Parent) : ModeHandler(Parent, "delayjoin", 'D', PARAM_NONE, MODETYPE_CHANNEL) { @@ -52,7 +51,7 @@ class ModuleDelayJoin : public Module void OnUserPart(Membership*, std::string &partmessage, CUList&) CXX11_OVERRIDE; void OnUserKick(User* source, Membership*, const std::string &reason, CUList&) CXX11_OVERRIDE; void OnBuildNeighborList(User* source, IncludeChanList& include, std::map<User*, bool>& exception) CXX11_OVERRIDE; - void OnText(User* user, void* dest, int target_type, const std::string &text, char status, CUList &exempt_list) CXX11_OVERRIDE; + void OnUserMessage(User* user, const MessageTarget& target, const MessageDetails& details) CXX11_OVERRIDE; ModResult OnRawMode(User* user, Channel* channel, ModeHandler* mh, const std::string& param, bool adding) CXX11_OVERRIDE; }; @@ -68,9 +67,13 @@ ModeAction DelayJoinMode::OnModeChange(User* source, User* dest, Channel* channe * Make all users visible, as +D is being removed. If we don't do this, * they remain permanently invisible on this channel! */ + MessageTarget msgtarget(channel, 0); + MessageDetails msgdetails(MSG_PRIVMSG, ""); const Channel::MemberMap& users = channel->GetUsers(); for (Channel::MemberMap::const_iterator n = users.begin(); n != users.end(); ++n) - creator->OnText(n->first, channel, TYPE_CHANNEL, "", 0, empty); + { + creator->OnUserMessage(n->first, msgtarget, msgdetails); + } } channel->SetMode(this, adding); return MODEACTION_ALLOW; @@ -138,12 +141,12 @@ void ModuleDelayJoin::OnBuildNeighborList(User* source, IncludeChanList& include } } -void ModuleDelayJoin::OnText(User* user, void* dest, int target_type, const std::string &text, char status, CUList &exempt_list) +void ModuleDelayJoin::OnUserMessage(User* user, const MessageTarget& target, const MessageDetails& details) { - if (target_type != TYPE_CHANNEL) + if (target.type != MessageTarget::TYPE_CHANNEL) return; - Channel* channel = static_cast<Channel*>(dest); + Channel* channel = target.Get<Channel>(); Membership* memb = channel->GetUser(user); if (!memb || !unjoined.set(memb, 0)) |