]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_testcommand.cpp
Gah, im forgetting to SetMode!
[user/henk/code/inspircd.git] / src / modules / m_testcommand.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
6  *                       E-mail:
7  *                <brain@chatspike.net>
8  *                <Craig@chatspike.net>
9  *     
10  * Written by Craig Edwards, Craig McLure, and others.
11  * This program is free but copyrighted software; see
12  *            the file COPYING for details.
13  *
14  * ---------------------------------------------------
15  */
16
17 using namespace std;
18
19 #include <stdio.h>
20 #include "users.h"
21 #include "channels.h"
22 #include "modules.h"
23
24 /* $ModDesc: Povides a proof-of-concept test /WOOT command */
25
26 static Server *Srv;
27          
28 class cmd_woot : public command_t
29 {
30  public:
31         cmd_woot () : command_t("WOOT", 0, 0)
32         {
33                 this->source = "m_testcommand.so";
34         }
35
36         void Handle (char **parameters, int pcnt, userrec *user)
37         {
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.
42                 
43                 // NOTE: DO NOT CODE LIKE THIS!!! This has no checks and can send
44                 // invalid or plain confusing mode changes, code some checking!
45                 char* modes[3];
46                 modes[0] = "#chatspike";
47                 modes[1] = "+o";
48                 modes[2] = user->nick;
49                 
50                 // run the mode change, send numerics (such as "no such channel") back
51                 // to "user".
52                 Srv->SendMode(modes,3,user);
53         }
54 };
55
56 class ModuleTestCommand : public Module
57 {
58         cmd_woot* newcommand;
59  public:
60         ModuleTestCommand(Server* Me)
61                 : Module::Module(Me)
62         {
63                 Srv = 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);
72         }
73
74         void Implements(char* List)
75         {
76                 List[I_OnUserJoin] = 1;
77         }
78
79         virtual void OnUserJoin(userrec* user, chanrec* channel)
80         {
81         }
82         
83         virtual ~ModuleTestCommand()
84         {
85         }
86         
87         virtual Version GetVersion()
88         {
89                 return Version(1,0,0,0,VF_STATIC|VF_VENDOR);
90         }
91 };
92
93
94 class ModuleTestCommandFactory : public ModuleFactory
95 {
96  public:
97         ModuleTestCommandFactory()
98         {
99         }
100         
101         ~ModuleTestCommandFactory()
102         {
103         }
104         
105         virtual Module * CreateModule(Server* Me)
106         {
107                 return new ModuleTestCommand(Me);
108         }
109         
110 };
111
112
113 extern "C" void * init_module( void )
114 {
115         return new ModuleTestCommandFactory;
116 }
117