7 /* $ModDesc: Povides a proof-of-concept test /WOOT command */
12 void handle_woot(char **parameters, int pcnt, userrec *user)
14 Srv->Log(DEBUG,"woot handler");
15 // Here is a sample of how to send servermodes. Note that unless remote
16 // servers in your net are u:lined, they may reverse this, but its a
17 // quick and effective modehack.
19 // NOTE: DO NOT CODE LIKE THIS!!! This has no checks and can send
20 // invalid or plain confusing mode changes, code some checking!
22 modes[0] = "#chatspike";
24 modes[2] = user->nick;
26 // run the mode change, send numerics (such as "no such channel") back
28 Srv->SendMode(modes,3,user);
31 class ModuleTestCommand : public Module
37 // Create a new command:
38 // command will be called /WOOT, and will
39 // call handle_woot when triggered, the
40 // 0 in the modes parameter signifies that
41 // anyone can issue the command, and the
42 // command takes only one parameter.
43 Srv->AddCommand("WOOT",handle_woot,0,0);
45 // Add a mode +Z for channels with no parameters
46 Srv->AddExtendedMode('Z',MT_CHANNEL,false,1,0);
49 virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list ¶ms)
52 if ((modechar != 'Z') || (type != MT_CHANNEL)) {
53 // this mode isn't ours, we have to bail and return 0 to not handle it.
54 Srv->Log(DEBUG,"Extended mode event triggered, but this is not a mode i've claimed!");
58 chanrec* chan = (chanrec*)target;
61 Srv->Log(DEBUG,"Custom mode is being added to channel");
62 Srv->Log(DEBUG,chan->name);
65 Srv->Log(DEBUG,"Custom mode is being taken from a channel");
66 Srv->Log(DEBUG,chan->name);
69 // must return 1 to handle the mode!
73 virtual void OnUserJoin(userrec* user, chanrec* channel)
75 Srv->Log(DEBUG,"OnUserJoin triggered");
76 if (channel->IsCustomModeSet('Z'))
78 std::string param = channel->GetModeParameter('Z');
79 Srv->Log(DEBUG,"Custom mode is set on this channel! Parameter="+param);
83 virtual ~ModuleTestCommand()
88 virtual Version GetVersion()
90 return Version(1,0,0,0);
93 virtual void OnUserConnect(userrec* user)
100 class ModuleTestCommandFactory : public ModuleFactory
103 ModuleTestCommandFactory()
107 ~ModuleTestCommandFactory()
111 virtual Module * CreateModule()
113 return new ModuleTestCommand;
119 extern "C" void * init_module( void )
121 return new ModuleTestCommandFactory;