]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
m_hideoper: Hide hidden opers from /stats P. #874
authorAdam <Adam@anope.org>
Tue, 17 Jun 2014 12:49:37 +0000 (08:49 -0400)
committerAdam <Adam@anope.org>
Sat, 19 Jul 2014 20:55:27 +0000 (16:55 -0400)
src/modules/m_hideoper.cpp

index fbab9685f6c65b9909f997abf3f4829806a488aa..b83c7de1afc511f4eef737f527946938e3e8a89e 100644 (file)
@@ -46,7 +46,7 @@ class ModuleHideOper : public Module
        void init()
        {
                ServerInstance->Modules->AddService(hm);
-               Implementation eventlist[] = { I_OnWhoisLine, I_OnSendWhoLine };
+               Implementation eventlist[] = { I_OnWhoisLine, I_OnSendWhoLine, I_OnStats };
                ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
        }
 
@@ -90,6 +90,27 @@ class ModuleHideOper : public Module
                                line.clear();
                }
        }
+
+       ModResult OnStats(char symbol, User* user, string_list &results)
+       {
+               if (symbol != 'P')
+                       return MOD_RES_PASSTHRU;
+
+               unsigned int count = 0;
+               for (std::list<User*>::const_iterator i = ServerInstance->Users->all_opers.begin(); i != ServerInstance->Users->all_opers.end(); ++i)
+               {
+                       User* oper = *i;
+                       if (!ServerInstance->ULine(oper->server) && (IS_OPER(user) || !oper->IsModeSet('H')))
+                       {
+                               results.push_back(ServerInstance->Config->ServerName+" 249 " + user->nick + " :" + oper->nick + " (" + oper->ident + "@" + oper->dhost + ") Idle: " +
+                                               (IS_LOCAL(oper) ? ConvToStr(ServerInstance->Time() - oper->idle_lastmsg) + " secs" : "unavailable"));
+                               count++;
+                       }
+               }
+               results.push_back(ServerInstance->Config->ServerName+" 249 "+user->nick+" :"+ConvToStr(count)+" OPER(s)");
+
+               return MOD_RES_DENY;
+       }
 };