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 * ---------------------------------------------------
25 /* $ModDesc: Provides the /check command to retrieve information on a user, channel, or IP address */
29 class cmd_check : public command_t
32 cmd_check() : command_t("CHECK", 'o', 1)
34 this->source = "m_check.so";
37 void Handle (char **parameters, int pcnt, userrec *user)
42 std::string chliststr;
44 checkstr = "304 " + std::string(user->nick) + " :CHECK";
46 targuser = Srv->FindNick(std::string(parameters[0]));
47 targchan = Srv->FindChannel(std::string(parameters[0]));
50 * Syntax of a /check reply:
51 * :server.name 304 target :CHECK START <target>
52 * :server.name 304 target :CHECK <field> <value>
53 * :server.name 304 target :CHECK END
56 Srv->SendTo(NULL, user, checkstr + " START " + std::string(parameters[0]));
60 /* /check on a user */
61 Srv->SendTo(NULL, user, checkstr + " nuh " + std::string(targuser->GetFullHost()));
62 Srv->SendTo(NULL, user, checkstr + " realnuh " + std::string(targuser->GetFullRealHost()));
63 Srv->SendTo(NULL, user, checkstr + " realname " + std::string(targuser->fullname));
64 Srv->SendTo(NULL, user, checkstr + " modes +" + std::string(targuser->modes));
65 Srv->SendTo(NULL, user, checkstr + " server " + std::string(targuser->server));
66 if (targuser->awaymsg[0] != 0)
69 Srv->SendTo(NULL, user, checkstr + " awaymsg " + std::string(targuser->awaymsg));
71 if (targuser->oper[0] != 0)
73 /* user is an oper of type ____ */
74 Srv->SendTo(NULL, user, checkstr + " opertype " + std::string(targuser->oper));
76 if (IS_LOCAL(targuser))
78 /* port information is only held for a local user! */
79 Srv->SendTo(NULL, user, checkstr + " onport " + ConvToStr(targuser->port));
82 chliststr = chlist(targuser, targuser);
83 std::stringstream dump(chliststr);
84 /* XXX - This doent suck so much */
85 Srv->DumpText(user,checkstr + " onchans ", dump);
89 /* /check on a channel */
93 /* /check on an IP address, or something that doesn't exist */
96 Srv->SendTo(NULL, user, checkstr + " END " + std::string(parameters[0]));
101 class ModuleCheck : public Module
104 cmd_check *mycommand;
106 ModuleCheck(Server* Me) : Module::Module(Me)
109 mycommand = new cmd_check();
110 Srv->AddCommand(mycommand);
113 virtual ~ModuleCheck()
117 virtual Version GetVersion()
119 return Version(1, 0, 0, 0, VF_VENDOR);
122 void Implements(char* List)
124 /* we don't hook anything, nothing required */
131 class ModuleCheckFactory : public ModuleFactory
138 ~ModuleCheckFactory()
142 virtual Module * CreateModule(Server* Me)
144 return new ModuleCheck(Me);
149 extern "C" void * init_module( void )
151 return new ModuleCheckFactory;