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 /* $ModDesc: Provides the /check command to retrieve information on a user, channel, or IP address */
27 class cmd_check : public command_t
30 cmd_check() : command_t("CHECK", 'o', 1)
32 this->source = "m_check.so";
35 void Handle (char **parameters, int pcnt, userrec *user)
41 checkstr = "304 " + std::string(user->nick) + " :CHECK";
43 targuser = Srv->FindNick(std::string(parameters[0]));
44 targchan = Srv->FindChannel(std::string(parameters[0]));
47 * Syntax of a /check reply:
48 * :server.name 304 target :CHECK START <target>
49 * :server.name 304 target :CHECK <field> <value>
50 * :server.name 304 target :CHECK END
53 Srv->SendTo(NULL, user, checkstr + " START " + std::string(parameters[0]));
57 /* /check on a user */
58 Srv->SendTo(NULL, user, checkstr + " nuh " + std::string(targuser->GetFullHost()));
59 Srv->SendTo(NULL, user, checkstr + " realnuh " + std::string(targuser->GetFullRealHost()));
60 Srv->SendTo(NULL, user, checkstr + " realname " + std::string(targuser->fullname));
61 Srv->SendTo(NULL, user, checkstr + " modes +" + std::string(targuser->modes));
62 Srv->SendTo(NULL, user, checkstr + " server " + std::string(targuser->server));
63 if (targuser->awaymsg[0] != 0)
66 Srv->SendTo(NULL, user, checkstr + " awaymsg " + std::string(targuser->awaymsg));
68 if (targuser->oper[0] != 0)
70 /* user is an oper of type ____ */
71 Srv->SendTo(NULL, user, checkstr + " opertype " + std::string(targuser->oper));
73 if (IS_LOCAL(targuser))
75 /* port information is only held for a local user! */
76 Srv->SendTo(NULL, user, checkstr + " onport " + ConvToStr(targuser->port));
81 /* /check on a channel */
85 /* /check on an IP address, or something that doesn't exist */
88 Srv->SendTo(NULL, user, "304 " + std::string(user->nick) + " :CHECK END " + std::string(parameters[0]));
93 class ModuleCheck : public Module
98 ModuleCheck(Server* Me) : Module::Module(Me)
101 mycommand = new cmd_check();
102 Srv->AddCommand(mycommand);
105 virtual ~ModuleCheck()
109 virtual Version GetVersion()
111 return Version(1, 0, 0, 0, VF_VENDOR);
114 void Implements(char* List)
116 /* we don't hook anything, nothing required */
123 class ModuleCheckFactory : public ModuleFactory
130 ~ModuleCheckFactory()
134 virtual Module * CreateModule(Server* Me)
136 return new ModuleCheck(Me);
141 extern "C" void * init_module( void )
143 return new ModuleCheckFactory;