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
This commit is contained in:
attilamolnar 2013-02-11 17:52:21 +01:00
parent 1f541d7bbc
commit a0f92dd232
2 changed files with 29 additions and 23 deletions

View File

@ -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

View File

@ -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));
}