1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2007 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
22 /* $ModDesc: Provides /tline command used to test who a mask matches */
26 class cmd_tline : public command_t
29 cmd_tline (InspIRCd* Instance) : command_t(Instance,"TLINE", 'o', 1)
31 this->source = "m_tline.so";
32 this->syntax = "<mask>";
35 CmdResult Handle (const char** parameters, int pcnt, userrec *user)
39 float n_match_host = 0;
42 for (user_hash::const_iterator u = ServerInstance->clientlist->begin(); u != ServerInstance->clientlist->end(); u++)
45 if (match(u->second->GetFullRealHost(),parameters[0]))
53 snprintf(host, MAXBUF, "%s@%s", u->second->ident, u->second->GetIPString());
54 if (match(host, parameters[0], true))
62 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);
64 user->WriteServ( "NOTICE %s :*** TLINE: Counted %0.0f user(s). Matched '%s' against no user(s).", user->nick, n_counted, parameters[0]);
71 class ModuleTLine : public Module
73 cmd_tline* newcommand;
75 ModuleTLine(InspIRCd* Me)
79 newcommand = new cmd_tline(ServerInstance);
80 ServerInstance->AddCommand(newcommand);
83 void Implements(char* List)
87 virtual ~ModuleTLine()
91 virtual Version GetVersion()
93 return Version(1, 1, 0, 0, VF_VENDOR,API_VERSION);
98 class ModuleTLineFactory : public ModuleFactory
105 ~ModuleTLineFactory()
109 virtual Module * CreateModule(InspIRCd* Me)
111 return new ModuleTLine(Me);
117 extern "C" void * init_module( void )
119 return new ModuleTLineFactory;