7 /* $ModDesc: Povides a proof-of-concept test /WOOT command */
12 void handle_woot(char **parameters, int pcnt, userrec *user)
14 // this test command just accepts:
16 // and sends <text> to all opers with +s mode.
17 // NB: The ':' is *REQUIRED* otherwise the parser will
18 // split the line into multiple parameters[]!
20 // If you want to process all the line with no leading colon, you must
21 // implement a parser here that assembles parameters[] to match the
22 // syntax of your command - the way it is done in the core is to meet
24 Srv->SendOpers(parameters[0]);
27 // Here is a sample of how to send servermodes. Note that unless remote
28 // servers in your net are u:lined, they may reverse this, but its a
29 // quick and effective modehack.
31 // NOTE: DO NOT CODE LIKE THIS!!! This has no checks and can send
32 // invalid or plain confusing mode changes, code some checking!
34 modes[0] = "#chatspike";
36 modes[2] = user->nick;
38 // run the mode change, send numerics (such as "no such channel") back
40 Srv->SendMode(modes,3,user);
43 class ModuleTestCommand : public Module
49 // Create a new command:
50 // command will be called /WOOT, and will
51 // call handle_woot when triggered, the
52 // 0 in the modes parameter signifies that
53 // anyone can issue the command, and the
54 // command takes only one parameter.
55 Srv->AddCommand("WOOT",handle_woot,0,1);
57 // Add a mode +Z for channels with no parameters
58 Srv->AddExtendedMode('Z',MT_CHANNEL,false,1,0);
61 virtual bool OnExtendedMode(userrec* user, chanrec* chan, char modechar, int type, bool mode_on, string_list ¶ms)
63 if ((modechar != 'Z') || (type != MT_CHANNEL)) {
64 // this mode isn't ours, we have to bail and return 0 to not handle it.
65 Srv->Log(DEBUG,"Extended mode event triggered, but this is not a mode i've claimed!");
71 Srv->Log(DEBUG,"Custom mode is being added to channel");
74 Srv->Log(DEBUG,"Custom mode is being taken from a channel");
76 Srv->Log(DEBUG,chan->name);
78 // must return 1 to handle the mode!
82 virtual void OnUserJoin(userrec* user, chanrec* channel)
84 Srv->Log(DEBUG,"OnUserJoin triggered");
85 if (channel->IsCustomModeSet('Z'))
87 std::string param = channel->GetModeParameter('Z');
88 Srv->Log(DEBUG,"Custom mode is set on this channel! Parameter="+param);
92 virtual ~ModuleTestCommand()
97 virtual Version GetVersion()
99 return Version(1,0,0,0);
102 virtual void OnUserConnect(userrec* user)
109 class ModuleTestCommandFactory : public ModuleFactory
112 ModuleTestCommandFactory()
116 ~ModuleTestCommandFactory()
120 virtual Module * CreateModule()
122 return new ModuleTestCommand;
128 extern "C" void * init_module( void )
130 return new ModuleTestCommandFactory;