From fd87f9f073dff6e2f21a92c96144fb6c0a46e8e3 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Sun, 6 Dec 2015 11:24:39 +0100 Subject: Add minimum channel rank and exception list parameters to the OnUserInvite hook --- include/modules.h | 4 +++- src/coremods/core_channel/cmd_invite.cpp | 13 ++++++++++--- src/modules.cpp | 2 +- src/modules/m_spanningtree/main.cpp | 2 +- src/modules/m_spanningtree/main.h | 2 +- 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/include/modules.h b/include/modules.h index 93e5c05a0..526c283b2 100644 --- a/include/modules.h +++ b/include/modules.h @@ -487,8 +487,10 @@ class CoreExport Module : public classbase, public usecountbase * @param dest The user being invited * @param channel The channel the user is being invited to * @param timeout The time the invite will expire (0 == never) + * @param notifyrank Rank required to get an invite announcement (if enabled) + * @param notifyexcepts List of users to not send the default NOTICE invite announcement to */ - virtual void OnUserInvite(User* source,User* dest,Channel* channel, time_t timeout); + virtual void OnUserInvite(User* source, User* dest, Channel* channel, time_t timeout, unsigned int notifyrank, CUList& notifyexcepts); /** Called whenever a user is about to PRIVMSG A user or a channel, before any processing is done. * Returning any nonzero value from this function stops the process immediately, causing no diff --git a/src/coremods/core_channel/cmd_invite.cpp b/src/coremods/core_channel/cmd_invite.cpp index 55ed33f7f..c1f1b00c7 100644 --- a/src/coremods/core_channel/cmd_invite.cpp +++ b/src/coremods/core_channel/cmd_invite.cpp @@ -123,17 +123,23 @@ CmdResult CommandInvite::Handle (const std::vector& parameters, Use } char prefix = 0; + unsigned int minrank = 0; switch (ServerInstance->Config->AnnounceInvites) { case ServerConfig::INVITE_ANNOUNCE_OPS: { prefix = '@'; + minrank = OP_VALUE; break; } case ServerConfig::INVITE_ANNOUNCE_DYNAMIC: { PrefixMode* mh = ServerInstance->Modes->FindPrefixMode('h'); - prefix = (mh && mh->name == "halfop" ? mh->GetPrefix() : '@'); + if ((mh) && (mh->name == "halfop")) + { + prefix = mh->GetPrefix(); + minrank = mh->GetPrefixRank(); + } break; } default: @@ -141,10 +147,11 @@ CmdResult CommandInvite::Handle (const std::vector& parameters, Use } } - FOREACH_MOD(OnUserInvite, (user, u, c, timeout)); + CUList excepts; + FOREACH_MOD(OnUserInvite, (user, u, c, timeout, minrank, excepts)); if (ServerInstance->Config->AnnounceInvites != ServerConfig::INVITE_ANNOUNCE_NONE) - c->WriteAllExceptSender(user, true, prefix, "NOTICE %s :*** %s invited %s into the channel", c->name.c_str(), user->nick.c_str(), u->nick.c_str()); + c->WriteAllExcept(user, true, prefix, excepts, "NOTICE %s :*** %s invited %s into the channel", c->name.c_str(), user->nick.c_str(), u->nick.c_str()); } else if (IS_LOCAL(user)) { diff --git a/src/modules.cpp b/src/modules.cpp index d77221c39..292986df5 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -114,7 +114,7 @@ ModResult Module::OnPreTopicChange(User*, Channel*, const std::string&) { Detach ModResult Module::OnPassCompare(Extensible* ex, const std::string &password, const std::string &input, const std::string& hashtype) { DetachEvent(I_OnPassCompare); return MOD_RES_PASSTHRU; } void Module::OnPostConnect(User*) { DetachEvent(I_OnPostConnect); } void Module::OnUserMessage(User*, void*, int, const std::string&, char, const CUList&, MessageType) { DetachEvent(I_OnUserMessage); } -void Module::OnUserInvite(User*, User*, Channel*, time_t) { DetachEvent(I_OnUserInvite); } +void Module::OnUserInvite(User*, User*, Channel*, time_t, unsigned int, CUList&) { DetachEvent(I_OnUserInvite); } void Module::OnPostTopicChange(User*, Channel*, const std::string&) { DetachEvent(I_OnPostTopicChange); } void Module::OnSyncUser(User*, ProtocolInterface::Server&) { DetachEvent(I_OnSyncUser); } void Module::OnSyncChannel(Channel*, ProtocolInterface::Server&) { DetachEvent(I_OnSyncChannel); } diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index 98cf3188f..4e45b4fe8 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -358,7 +358,7 @@ ModResult ModuleSpanningTree::HandleConnect(const std::vector& para return MOD_RES_DENY; } -void ModuleSpanningTree::OnUserInvite(User* source,User* dest,Channel* channel, time_t expiry) +void ModuleSpanningTree::OnUserInvite(User* source, User* dest, Channel* channel, time_t expiry, unsigned int notifyrank, CUList& notifyexcepts) { if (IS_LOCAL(source)) { diff --git a/src/modules/m_spanningtree/main.h b/src/modules/m_spanningtree/main.h index 9fde32cad..d29609a35 100644 --- a/src/modules/m_spanningtree/main.h +++ b/src/modules/m_spanningtree/main.h @@ -149,7 +149,7 @@ class ModuleSpanningTree : public Module ModResult OnPreCommand(std::string &command, std::vector& parameters, LocalUser *user, bool validated, const std::string &original_line) CXX11_OVERRIDE; void OnPostCommand(Command*, const std::vector& parameters, LocalUser* user, CmdResult result, const std::string& original_line) CXX11_OVERRIDE; void OnUserConnect(LocalUser* source) CXX11_OVERRIDE; - void OnUserInvite(User* source,User* dest,Channel* channel, time_t) CXX11_OVERRIDE; + void OnUserInvite(User* source, User* dest, Channel* channel, time_t timeout, unsigned int notifyrank, CUList& notifyexcepts) CXX11_OVERRIDE; void OnPostTopicChange(User* user, Channel* chan, const std::string &topic) CXX11_OVERRIDE; void OnUserMessage(User* user, void* dest, int target_type, const std::string& text, char status, const CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE; void OnBackgroundTimer(time_t curtime) CXX11_OVERRIDE; -- cgit v1.2.3