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 * ---------------------------------------------------
24 /* $ModDesc: Povides a proof-of-concept test /WOOT command */
28 class cmd_woot : public command_t
31 cmd_woot () : command_t("WOOT", 0, 0)
33 this->source = "m_testcommand.so";
36 void Handle (char **parameters, int pcnt, userrec *user)
38 Srv->Log(DEBUG,"woot handler");
39 // Here is a sample of how to send servermodes. Note that unless remote
40 // servers in your net are u:lined, they may reverse this, but its a
41 // quick and effective modehack.
43 // NOTE: DO NOT CODE LIKE THIS!!! This has no checks and can send
44 // invalid or plain confusing mode changes, code some checking!
46 modes[0] = "#chatspike";
48 modes[2] = user->nick;
50 // run the mode change, send numerics (such as "no such channel") back
52 Srv->SendMode(modes,3,user);
56 class ModuleTestCommand : public Module
60 ModuleTestCommand(Server* Me)
64 // Create a new command:
65 // command will be called /WOOT, and will
66 // call handle_woot when triggered, the
67 // 0 in the modes parameter signifies that
68 // anyone can issue the command, and the
69 // command takes only one parameter.
70 newcommand = new cmd_woot();
71 Srv->AddCommand(newcommand);
73 // Add a mode +Z for channels with no parameters
74 Srv->AddExtendedMode('Z',MT_CHANNEL,false,1,0);
77 void Implements(char* List)
79 List[I_OnExtendedMode] = List[I_OnUserJoin] = 1;
82 virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list ¶ms)
85 if ((modechar != 'Z') || (type != MT_CHANNEL))
87 // this mode isn't ours, we have to bail and return 0 to not handle it.
88 Srv->Log(DEBUG,"Extended mode event triggered, but this is not a mode i've claimed!");
92 chanrec* chan = (chanrec*)target;
96 Srv->Log(DEBUG,"Custom mode is being added to channel");
97 Srv->Log(DEBUG,chan->name);
101 Srv->Log(DEBUG,"Custom mode is being taken from a channel");
102 Srv->Log(DEBUG,chan->name);
105 // must return 1 to handle the mode!
109 virtual void OnUserJoin(userrec* user, chanrec* channel)
111 Srv->Log(DEBUG,"OnUserJoin triggered");
112 if (channel->IsModeSet('Z'))
114 std::string param = channel->GetModeParameter('Z');
115 Srv->Log(DEBUG,"Custom mode is set on this channel! Parameter="+param);
119 virtual ~ModuleTestCommand()
123 virtual Version GetVersion()
125 return Version(1,0,0,0,VF_STATIC|VF_VENDOR);
130 class ModuleTestCommandFactory : public ModuleFactory
133 ModuleTestCommandFactory()
137 ~ModuleTestCommandFactory()
141 virtual Module * CreateModule(Server* Me)
143 return new ModuleTestCommand(Me);
149 extern "C" void * init_module( void )
151 return new ModuleTestCommandFactory;