1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
7 * <brain@chatspike.net>
8 * <Craig@chatspike.net>
10 * Written by Craig Edwards, Craig McLure, and others.
11 * This program is free but copyrighted software; see
12 * the file COPYING for details.
14 * ---------------------------------------------------
27 /* $ModDesc: Provides /tline command used to test who a mask matches */
31 class cmd_tline : public command_t
34 cmd_tline (InspIRCd* Instance) : command_t(Instance,"TLINE", 'o', 1)
36 this->source = "m_tline.so";
37 this->syntax = "<mask>";
40 CmdResult Handle (const char** parameters, int pcnt, userrec *user)
44 float n_match_host = 0;
47 for (user_hash::const_iterator u = ServerInstance->clientlist.begin(); u != ServerInstance->clientlist.end(); u++)
50 if (match(u->second->GetFullRealHost(),parameters[0]))
58 snprintf(host, MAXBUF, "%s@%s", u->second->ident, u->second->GetIPString());
59 if (match(host, parameters[0], true))
67 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, n_counted, parameters[0], n_matched, (n_matched/n_counted)*100, n_match_host, n_match_ip);
69 user->WriteServ( "NOTICE %s :*** TLINE: Counted %0.0f user(s). Matched '%s' against no user(s).", user->nick, n_counted, parameters[0]);
76 class ModuleTLine : public Module
78 cmd_tline* newcommand;
80 ModuleTLine(InspIRCd* Me)
84 newcommand = new cmd_tline(ServerInstance);
85 ServerInstance->AddCommand(newcommand);
88 void Implements(char* List)
92 virtual ~ModuleTLine()
96 virtual Version GetVersion()
98 return Version(1, 1, 0, 0, VF_VENDOR,API_VERSION);
103 class ModuleTLineFactory : public ModuleFactory
110 ~ModuleTLineFactory()
114 virtual Module * CreateModule(InspIRCd* Me)
116 return new ModuleTLine(Me);
122 extern "C" void * init_module( void )
124 return new ModuleTLineFactory;