]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Add option to set invite announcements to nobody, ops only, or all users, based on...
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Sun, 26 Aug 2007 20:43:15 +0000 (20:43 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Sun, 26 Aug 2007 20:43:15 +0000 (20:43 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7837 e03df62e-2008-0410-955e-edbf42e46eb7

docs/inspircd.conf.example
include/configreader.h
src/cmd_invite.cpp
src/configreader.cpp

index 33840ac287db21e87a6ab2f9fa9ad527139a42e5..ce0432220d3c685eb970d155bfefa24c60328f26 100644 (file)
 #                  if set to no, then only the nickname is shown.     #
 #                                                                     #
 # announceinvites                                                     #
-#                - If this option is set to yes (the default), then   #
-#                  invites are announced to the channel when a user   #
-#                  invites annother user. If you consider this to be  #
-#                  unnecessary noise, explicitly set this to no.      #
+#                - If this option is set, then invites are announced  #
+#                  to the channel when a user invites annother 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'.                                    #
 #                                                                     #
 #  disablehmac   - If you are linking your InspIRCd to older versions #
 #                  then you can specify this option and set it to     #
         serverpingfreq="60"
          allowhalfop="yes"
         defaultmodes="nt"
+        announceinvites="all"
         moronbanner="You're banned! Email haha@abuse.com with the ERROR line below for help."
         exemptchanops="">
 
index 648b02eb1b26889edc912bda29761ff7e3dc349e..703c284142136c5b5beb4b30b191c1bcbf8dfa6a 100644 (file)
@@ -239,7 +239,10 @@ class CoreExport ServerConfig : public Extensible
   
   public:
 
-       /* Pointer to function that validates dns server addresses (can be changed depending on platform) */
+       /** Used to indicate who we announce invites to on a channel */
+       enum InviteAnnounceState { INVITE_ANNOUNCE_NONE, INVITE_ANNOUNCE_ALL, INVITE_ANNOUNCE_OPS };
+
+       /** Pointer to function that validates dns server addresses (can be changed depending on platform) */
        Validator DNSServerValidator;
 
        InspIRCd* GetInstance();
@@ -459,7 +462,7 @@ class CoreExport ServerConfig : public Extensible
 
        /** Announce invites to the channel with a server notice
         */
-       bool AnnounceInvites;
+       InviteAnnounceState AnnounceInvites;
 
        /** If this is enabled then operators will
         * see invisible (+i) channels in /whois.
index f4368071a7ffacb2b2dd6d9bef7a6bbfc27eef37..a6e82d281de98cd8e3bab2ce8faf2985b3341286 100644 (file)
@@ -78,8 +78,18 @@ CmdResult cmd_invite::Handle (const char** parameters, int pcnt, userrec *user)
                u->InviteTo(c->name);
                u->WriteFrom(user,"INVITE %s :%s",u->nick,c->name);
                user->WriteServ("341 %s %s %s",user->nick,u->nick,c->name);
-               if (ServerInstance->Config->AnnounceInvites)
-                       c->WriteChannelWithServ(ServerInstance->Config->ServerName, "NOTICE %s :*** %s invited %s into the channel", c->name, user->nick, u->nick);
+               switch (ServerInstance->Config->AnnounceInvites)
+               {
+                       case ServerConfig::INVITE_ANNOUNCE_ALL:
+                               c->WriteChannelWithServ(ServerInstance->Config->ServerName, "NOTICE %s :*** %s invited %s into the channel", c->name, user->nick, u->nick);
+                       break;
+                       case ServerConfig::INVITE_ANNOUNCE_OPS:
+                               c->WriteAllExceptSender(user, true, '@', "NOTICE %s :*** %s invited %s into the channel", c->name, user->nick, u->nick);
+                       break;
+                       default:
+                               /* Nobody */
+                       break;
+               }
                FOREACH_MOD(I_OnUserInvite,OnUserInvite(user,u,c));
        }
        else
index e6aa30de32ed3e5c3a311955740c27e902a789f6..06a86a77528d8f0496ade64d256f67a9ca194d23 100644 (file)
@@ -353,6 +353,20 @@ bool ValidateExemptChanOps(ServerConfig* conf, const char* tag, const char* valu
        return true;
 }
 
+bool ValidateInvite(ServerConfig* conf, const char* tag, const char* value, ValueItem &data)
+{
+       std::string v = data.GetString();
+
+       if (v == "ops")
+               conf->AnnounceInvites = ServerConfig::INVITE_ANNOUNCE_OPS;
+       else if (v == "all")
+               conf->AnnounceInvites = ServerConfig::INVITE_ANNOUNCE_ALL;
+       else
+               conf->AnnounceInvites = ServerConfig::INVITE_ANNOUNCE_NONE;
+
+       return true;
+}
+
 bool ValidateWhoWas(ServerConfig* conf, const char* tag, const char* value, ValueItem &data)
 {
        conf->WhoWasMaxKeep = conf->GetInstance()->Duration(data.GetString());
@@ -605,6 +619,7 @@ void ServerConfig::Read(bool bail, userrec* user)
        static char maxkeep[MAXBUF];    /* Temporary buffer for WhoWasMaxKeep value */
        static char hidemodes[MAXBUF];  /* Modes to not allow listing from users below halfop */
        static char exemptchanops[MAXBUF];      /* Exempt channel ops from these modes */
+       static char announceinvites[MAXBUF];    /* options:announceinvites setting */
        int rem = 0, add = 0;           /* Number of modules added, number of modules removed */
        std::ostringstream errstr;      /* String stream containing the error output */
 
@@ -649,7 +664,7 @@ void ServerConfig::Read(bool bail, userrec* user)
                {"options",     "syntaxhints",  "0",                    new ValueContainerBool (&this->SyntaxHints),            DT_BOOLEAN, NoValidation},
                {"options",     "cyclehosts",   "0",                    new ValueContainerBool (&this->CycleHosts),             DT_BOOLEAN, NoValidation},
                {"options",     "ircumsgprefix","0",                    new ValueContainerBool (&this->UndernetMsgPrefix),      DT_BOOLEAN, NoValidation},
-               {"options",     "announceinvites", "1",                 new ValueContainerBool (&this->AnnounceInvites),        DT_BOOLEAN, NoValidation},
+               {"options",     "announceinvites", "1",                 new ValueContainerChar (announceinvites),               DT_CHARPTR, ValidateInvite},
                {"options",     "hostintopic",  "1",                    new ValueContainerBool (&this->FullHostInTopic),        DT_BOOLEAN, NoValidation},
                {"options",     "hidemodes",    "",                     new ValueContainerChar (hidemodes),                     DT_CHARPTR, ValidateModeLists},
                {"options",     "exemptchanops","",                     new ValueContainerChar (exemptchanops),                 DT_CHARPTR, ValidateExemptChanOps},