1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * Inspire is copyright (C) 2002-2004 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 * ---------------------------------------------------
22 /* $ModDesc: Povides a proof-of-concept test /WOOT command */
27 void handle_woot(char **parameters, int pcnt, userrec *user)
29 Srv->Log(DEBUG,"woot handler");
30 // Here is a sample of how to send servermodes. Note that unless remote
31 // servers in your net are u:lined, they may reverse this, but its a
32 // quick and effective modehack.
34 // NOTE: DO NOT CODE LIKE THIS!!! This has no checks and can send
35 // invalid or plain confusing mode changes, code some checking!
37 modes[0] = "#chatspike";
39 modes[2] = user->nick;
41 // run the mode change, send numerics (such as "no such channel") back
43 Srv->SendMode(modes,3,user);
46 class ModuleTestCommand : public Module
52 // Create a new command:
53 // command will be called /WOOT, and will
54 // call handle_woot when triggered, the
55 // 0 in the modes parameter signifies that
56 // anyone can issue the command, and the
57 // command takes only one parameter.
58 Srv->AddCommand("WOOT",handle_woot,0,0,"m_testcommand.so");
60 // Add a mode +Z for channels with no parameters
61 Srv->AddExtendedMode('Z',MT_CHANNEL,false,1,0);
64 virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list ¶ms)
67 if ((modechar != 'Z') || (type != MT_CHANNEL)) {
68 // this mode isn't ours, we have to bail and return 0 to not handle it.
69 Srv->Log(DEBUG,"Extended mode event triggered, but this is not a mode i've claimed!");
73 chanrec* chan = (chanrec*)target;
76 Srv->Log(DEBUG,"Custom mode is being added to channel");
77 Srv->Log(DEBUG,chan->name);
80 Srv->Log(DEBUG,"Custom mode is being taken from a channel");
81 Srv->Log(DEBUG,chan->name);
84 // must return 1 to handle the mode!
88 virtual void OnUserJoin(userrec* user, chanrec* channel)
90 Srv->Log(DEBUG,"OnUserJoin triggered");
91 if (channel->IsCustomModeSet('Z'))
93 std::string param = channel->GetModeParameter('Z');
94 Srv->Log(DEBUG,"Custom mode is set on this channel! Parameter="+param);
98 virtual ~ModuleTestCommand()
103 virtual Version GetVersion()
105 return Version(1,0,0,0,VF_STATIC|VF_VENDOR);
108 virtual void OnUserConnect(userrec* user)
115 class ModuleTestCommandFactory : public ModuleFactory
118 ModuleTestCommandFactory()
122 ~ModuleTestCommandFactory()
126 virtual Module * CreateModule()
128 return new ModuleTestCommand;
134 extern "C" void * init_module( void )
136 return new ModuleTestCommandFactory;