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 * ---------------------------------------------------
23 #include "helperfuncs.h"
27 /* $ModDesc: Provides /tline command used to test who a mask matches */
30 extern user_hash clientlist;
32 class cmd_tline : public command_t
35 cmd_tline () : command_t("TLINE", 'o', 1)
37 this->source = "m_tline.so";
38 this->syntax = "<mask>";
41 void Handle (const char** parameters, int pcnt, userrec *user)
45 float n_match_host = 0;
48 for (user_hash::const_iterator u = clientlist.begin(); u != clientlist.end(); u++)
51 if (match(u->second->GetFullRealHost(),parameters[0]))
59 sprintf(host, "%s@%s", u->second->ident, u->second->GetIPString());
60 if (match(host, parameters[0], true))
68 WriteServ(user->fd, "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_counted/n_matched)*100, n_match_host, n_match_ip);
70 WriteServ(user->fd, "NOTICE %s :*** TLINE: Counted %0.0f user(s). Matched '%s' against no user(s).", user->nick, n_counted, parameters[0]);
75 class ModuleTLine : public Module
77 cmd_tline* newcommand;
79 ModuleTLine(Server* Me)
83 newcommand = new cmd_tline();
84 Srv->AddCommand(newcommand);
87 void Implements(char* List)
91 virtual ~ModuleTLine()
95 virtual Version GetVersion()
97 return Version(1,0,0,0,VF_STATIC|VF_VENDOR);
102 class ModuleTLineFactory : public ModuleFactory
109 ~ModuleTLineFactory()
113 virtual Module * CreateModule(Server* Me)
115 return new ModuleTLine(Me);
121 extern "C" void * init_module( void )
123 return new ModuleTLineFactory;