summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorattilamolnar <attilamolnar@hush.com>2013-02-11 17:52:21 +0100
committerattilamolnar <attilamolnar@hush.com>2013-02-11 17:52:21 +0100
commita0f92dd232097fa6662265ca49b222b72ca39c83 (patch)
treee42b66a6f0611ad898ecd2cdd453dc0937fb2915
parent1f541d7bbce6f2a254b3ba46ed9a31da593674de (diff)
cmd_invite Send invite announcements to halfops and higher when <security:announceinvites> is 'dynamic' regardless of the channel being +i or not
Clarify what the various options mean in the doc Fixes #418 reported by @RawrDragon
-rw-r--r--docs/conf/inspircd.conf.example14
-rw-r--r--src/commands/cmd_invite.cpp38
2 files changed, 29 insertions, 23 deletions
diff --git a/docs/conf/inspircd.conf.example b/docs/conf/inspircd.conf.example
index 22369bc50..fea9d5d5c 100644
--- a/docs/conf/inspircd.conf.example
+++ b/docs/conf/inspircd.conf.example
@@ -660,13 +660,13 @@
<security
- # announceinvites: If this option is set, then invites are announced
- # to the channel when a user invites another user. If you consider
- # this to be unnecessary noise, set this to 'none'.
- # To announce to all ops, set this to 'ops' and to announce to all users,
- # set the value to 'all'. The value 'dynamic' will make the messages
- # go to every user who has power of INVITE on the channel. This
- # is the recommended setting.
+ # announceinvites: This option controls which members of the channel
+ # receive an announcement when someone is INVITEd. Available values:
+ # 'none' - don't send invite announcements
+ # 'all' - send invite announcements to all members
+ # 'ops' - send invite announcements to ops and higher ranked users
+ # 'dynamic' - send invite announcements to halfops (if available) and
+ # higher ranked users. This is the recommended setting.
announceinvites="dynamic"
# hidemodes: If enabled, then the listmodes given will be hidden
diff --git a/src/commands/cmd_invite.cpp b/src/commands/cmd_invite.cpp
index e12b8244f..fd595d618 100644
--- a/src/commands/cmd_invite.cpp
+++ b/src/commands/cmd_invite.cpp
@@ -110,23 +110,29 @@ CmdResult CommandInvite::Handle (const std::vector<std::string>& parameters, Use
IS_LOCAL(u)->InviteTo(c->name.c_str(), timeout);
u->WriteFrom(user,"INVITE %s :%s",u->nick.c_str(),c->name.c_str());
user->WriteNumeric(RPL_INVITING, "%s %s %s",user->nick.c_str(),u->nick.c_str(),c->name.c_str());
- switch (ServerInstance->Config->AnnounceInvites)
+ if (ServerInstance->Config->AnnounceInvites != ServerConfig::INVITE_ANNOUNCE_NONE)
{
- case ServerConfig::INVITE_ANNOUNCE_ALL:
- c->WriteChannelWithServ(ServerInstance->Config->ServerName, "NOTICE %s :*** %s invited %s into the channel", c->name.c_str(), user->nick.c_str(), u->nick.c_str());
- break;
- case ServerConfig::INVITE_ANNOUNCE_OPS:
- c->WriteAllExceptSender(user, true, '@', "NOTICE %s :*** %s invited %s into the channel", c->name.c_str(), user->nick.c_str(), u->nick.c_str());
- break;
- case ServerConfig::INVITE_ANNOUNCE_DYNAMIC:
- if (c->IsModeSet('i'))
- c->WriteAllExceptSender(user, true, '@', "NOTICE %s :*** %s invited %s into the channel", c->name.c_str(), user->nick.c_str(), u->nick.c_str());
- else
- c->WriteChannelWithServ(ServerInstance->Config->ServerName, "NOTICE %s :*** %s invited %s into the channel", c->name.c_str(), user->nick.c_str(), u->nick.c_str());
- break;
- default:
- /* Nobody */
- break;
+ char prefix;
+ switch (ServerInstance->Config->AnnounceInvites)
+ {
+ case ServerConfig::INVITE_ANNOUNCE_OPS:
+ {
+ prefix = '@';
+ break;
+ }
+ case ServerConfig::INVITE_ANNOUNCE_DYNAMIC:
+ {
+ ModeHandler* mh = ServerInstance->Modes->FindMode('h', MODETYPE_CHANNEL);
+ prefix = (mh && mh->name == "halfop" ? mh->GetPrefix() : '@');
+ break;
+ }
+ default:
+ {
+ prefix = 0;
+ break;
+ }
+ }
+ 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());
}
FOREACH_MOD(I_OnUserInvite,OnUserInvite(user,u,c,timeout));
}