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"
26 /* $ModDesc: Povides a proof-of-concept test /WOOT command */
28 class MyResolver : public Resolver
31 MyResolver(const std::string &source, bool forward, const std::string &dnsserver = "") : Resolver(source, forward, dnsserver) { }
33 virtual void OnLookupComplete(const std::string &result)
35 log(DEBUG,"*** RESOLVER COMPLETED LOOKUP, IP IS: '%s'",result.c_str());
38 virtual void OnError(ResolverError e)
40 log(DEBUG,"*** RESOLVER GOT ERROR: %d",e);
46 class cmd_woot : public command_t
49 cmd_woot () : command_t("WOOT", 0, 0)
51 this->source = "m_testcommand.so";
54 void Handle (const char** parameters, int pcnt, userrec *user)
56 /* We dont have to worry about deleting 'r', the core will
57 * do it for us as required.*/
61 MyResolver* r = new MyResolver("brainbox.ath.cx", true);
64 catch (ModuleException& e)
66 log(DEBUG,"Danger, will robinson! There was an exception: %s",e.GetReason());
71 class ModuleTestCommand : public Module
75 ModuleTestCommand(Server* Me)
79 // Create a new command:
80 // command will be called /WOOT, and will
81 // call handle_woot when triggered, the
82 // 0 in the modes parameter signifies that
83 // anyone can issue the command, and the
84 // command takes only one parameter.
85 newcommand = new cmd_woot();
86 Srv->AddCommand(newcommand);
89 void Implements(char* List)
91 List[I_OnUserJoin] = 1;
94 virtual void OnUserJoin(userrec* user, chanrec* channel)
98 virtual ~ModuleTestCommand()
102 virtual Version GetVersion()
104 return Version(1,0,0,0,VF_STATIC|VF_VENDOR);
109 class ModuleTestCommandFactory : public ModuleFactory
112 ModuleTestCommandFactory()
116 ~ModuleTestCommandFactory()
120 virtual Module * CreateModule(Server* Me)
122 return new ModuleTestCommand(Me);
128 extern "C" void * init_module( void )
130 return new ModuleTestCommandFactory;