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 * ---------------------------------------------------
26 /* $ModDesc: Provides the /check command to retrieve information on a user, channel, or IP address */
30 class cmd_check : public command_t
33 cmd_check() : command_t("CHECK", 'o', 1)
35 this->source = "m_check.so";
38 void Handle (char **parameters, int pcnt, userrec *user)
43 std::string chliststr;
45 checkstr = "304 " + std::string(user->nick) + " :CHECK";
47 targuser = Srv->FindNick(std::string(parameters[0]));
48 targchan = Srv->FindChannel(std::string(parameters[0]));
51 * Syntax of a /check reply:
52 * :server.name 304 target :CHECK START <target>
53 * :server.name 304 target :CHECK <field> <value>
54 * :server.name 304 target :CHECK END
57 Srv->SendTo(NULL, user, checkstr + " START " + std::string(parameters[0]));
61 /* /check on a user */
62 Srv->SendTo(NULL, user, checkstr + " nuh " + std::string(targuser->GetFullHost()));
63 Srv->SendTo(NULL, user, checkstr + " realnuh " + std::string(targuser->GetFullRealHost()));
64 Srv->SendTo(NULL, user, checkstr + " realname " + std::string(targuser->fullname));
65 Srv->SendTo(NULL, user, checkstr + " modes +" + std::string(targuser->modes));
66 Srv->SendTo(NULL, user, checkstr + " server " + std::string(targuser->server));
67 if (targuser->awaymsg[0] != 0)
70 Srv->SendTo(NULL, user, checkstr + " awaymsg " + std::string(targuser->awaymsg));
72 if (targuser->oper[0] != 0)
74 /* user is an oper of type ____ */
75 Srv->SendTo(NULL, user, checkstr + " opertype " + std::string(targuser->oper));
77 if (IS_LOCAL(targuser))
79 /* port information is only held for a local user! */
80 Srv->SendTo(NULL, user, checkstr + " onport " + ConvToStr(targuser->port));
83 chliststr = chlist(targuser, targuser);
84 std::stringstream dump(chliststr);
85 /* XXX - This doent suck so much */
86 Srv->DumpText(user,checkstr + " onchans ", dump);
90 /* /check on a channel */
94 /* /check on an IP address, or something that doesn't exist */
97 Srv->SendTo(NULL, user, checkstr + " END " + std::string(parameters[0]));
102 class ModuleCheck : public Module
105 cmd_check *mycommand;
107 ModuleCheck(Server* Me) : Module::Module(Me)
110 mycommand = new cmd_check();
111 Srv->AddCommand(mycommand);
114 virtual ~ModuleCheck()
118 virtual Version GetVersion()
120 return Version(1, 0, 0, 0, VF_VENDOR);
123 void Implements(char* List)
125 /* we don't hook anything, nothing required */
132 class ModuleCheckFactory : public ModuleFactory
139 ~ModuleCheckFactory()
143 virtual Module * CreateModule(Server* Me)
145 return new ModuleCheck(Me);
150 extern "C" void * init_module( void )
152 return new ModuleCheckFactory;