void init()
{
- if (!ServerInstance->Modes->AddMode(&hm))
- throw ModuleException("Could not add new modes!");
- Implementation eventlist[] = { I_OnWhoisLine, I_OnSendWhoLine };
+ ServerInstance->Modules->AddService(hm);
+ Implementation eventlist[] = { I_OnWhoisLine, I_OnSendWhoLine, I_OnStats };
ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
}
if (user->IsModeSet('H') && !source->HasPrivPermission("users/auspex"))
{
// hide the "*" that marks the user as an oper from the /WHO line
- std::string::size_type pos = line.find("*");
+ std::string::size_type spcolon = line.find(" :");
+ if (spcolon == std::string::npos)
+ return; // Another module hid the user completely
+ std::string::size_type sp = line.rfind(' ', spcolon-1);
+ std::string::size_type pos = line.find('*', sp);
if (pos != std::string::npos)
line.erase(pos, 1);
// hide the line completely if doing a "/who * o" query
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;
+ }
};