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 if (chliststr.length())
85 if (chliststr.length() > 400)
87 /* XXX - this sucks. deal with it. */
88 std::stringstream chstream(chliststr);
89 std::string line = "";
90 std::string cname = "";
91 while (!chstream.eof())
94 line = line + cname + " ";
95 if (line.length() > 400)
97 Srv->SendTo(NULL, user, checkstr + " onchans " + line);
103 Srv->SendTo(NULL, user, checkstr + " onchans " + line);
108 Srv->SendTo(NULL, user, checkstr + " onchans " + chliststr);
114 /* /check on a channel */
118 /* /check on an IP address, or something that doesn't exist */
121 Srv->SendTo(NULL, user, checkstr + " END " + std::string(parameters[0]));
126 class ModuleCheck : public Module
129 cmd_check *mycommand;
131 ModuleCheck(Server* Me) : Module::Module(Me)
134 mycommand = new cmd_check();
135 Srv->AddCommand(mycommand);
138 virtual ~ModuleCheck()
142 virtual Version GetVersion()
144 return Version(1, 0, 0, 0, VF_VENDOR);
147 void Implements(char* List)
149 /* we don't hook anything, nothing required */
156 class ModuleCheckFactory : public ModuleFactory
163 ~ModuleCheckFactory()
167 virtual Module * CreateModule(Server* Me)
169 return new ModuleCheck(Me);
174 extern "C" void * init_module( void )
176 return new ModuleCheckFactory;