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) : Command(Instance,"TLINE", "o", 1)
25 this->source = "m_tline.so";
26 this->syntax = "<mask>";
29 CmdResult Handle (const std::vector<std::string> ¶meters, User *user)
33 float n_match_host = 0;
36 for (user_hash::const_iterator u = ServerInstance->Users->clientlist->begin(); u != ServerInstance->Users->clientlist->end(); u++)
39 if (InspIRCd::Match(u->second->GetFullRealHost(),parameters[0]))
46 std::string host = std::string(u->second->ident) + "@" + u->second->GetIPString();
47 if (InspIRCd::MatchCIDR(host, parameters[0]))
55 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);
57 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());
63 class ModuleTLine : public Module
65 CommandTline* newcommand;
67 ModuleTLine(InspIRCd* Me)
71 newcommand = new CommandTline(ServerInstance);
72 ServerInstance->AddCommand(newcommand);
77 virtual ~ModuleTLine()
81 virtual Version GetVersion()
83 return Version("$Id$", VF_VENDOR,API_VERSION);
87 MODULE_INIT(ModuleTLine)