1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2009 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
16 /* $ModDesc: Provides /tline command used to test who a mask matches */
20 class CommandTline : public Command
23 CommandTline (InspIRCd* Instance, Module* Creator) : Command(Instance, Creator,"TLINE", "o", 1)
25 this->syntax = "<mask>";
28 CmdResult Handle (const std::vector<std::string> ¶meters, User *user)
32 float n_match_host = 0;
35 for (user_hash::const_iterator u = ServerInstance->Users->clientlist->begin(); u != ServerInstance->Users->clientlist->end(); u++)
38 if (InspIRCd::Match(u->second->GetFullRealHost(),parameters[0]))
45 std::string host = std::string(u->second->ident) + "@" + u->second->GetIPString();
46 if (InspIRCd::MatchCIDR(host, parameters[0]))
54 user->WriteServ( "NOTICE %s :*** TLINE: Counted %0.0f user(s). Matched '%s' against %0.0f user(s) (%0.2f%% of the userbase). %0.0f by hostname and %0.0f by IP address.",user->nick.c_str(), n_counted, parameters[0].c_str(), n_matched, (n_matched/n_counted)*100, n_match_host, n_match_ip);
56 user->WriteServ( "NOTICE %s :*** TLINE: Counted %0.0f user(s). Matched '%s' against no user(s).", user->nick.c_str(), n_counted, parameters[0].c_str());
62 class ModuleTLine : public Module
66 ModuleTLine(InspIRCd* Me)
67 : Module(Me), cmd(Me, this)
69 ServerInstance->AddCommand(&cmd);
73 virtual ~ModuleTLine()
77 virtual Version GetVersion()
79 return Version("$Id$", VF_VENDOR,API_VERSION);
83 MODULE_INIT(ModuleTLine)