]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_userip.cpp
Added <oper:swhois> to m_swhois, which will override <type:swhois> if specified
[user/henk/code/inspircd.git] / src / modules / m_userip.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 <string>
21 #include "users.h"
22 #include "channels.h"
23 #include "modules.h"
24 #include "inspircd.h"
25
26 /* $ModDesc: Provides support for USERIP command */
27
28 /** Handle /USERIP
29  */
30 class cmd_userip : public command_t
31 {
32  public:
33         cmd_userip (InspIRCd* Instance) : command_t(Instance,"USERIP", 'o', 1)
34         {
35                 this->source = "m_userip.so";
36                 syntax = "<nick>{,<nick>}";
37         }
38
39         CmdResult Handle (const char** parameters, int pcnt, userrec *user)
40         {
41                 char Return[MAXBUF],junk[MAXBUF];
42                 snprintf(Return,MAXBUF,"340 %s :",user->nick);
43                 for (int i = 0; i < pcnt; i++)
44                 {
45                         userrec *u = ServerInstance->FindNick(parameters[i]);
46                         if ((u) && (u->registered == REG_ALL))
47                         {
48                                 snprintf(junk,MAXBUF,"%s%s=+%s@%s ",u->nick,*u->oper ? "*" : "",u->ident,u->GetIPString());
49                                 strlcat(Return,junk,MAXBUF);
50                         }
51                 }
52                 user->WriteServ(Return);
53
54                 /* Dont send to the network */
55                 return CMD_FAILURE;
56         }
57 };
58
59 class ModuleUserIP : public Module
60 {
61         cmd_userip* mycommand;
62  public:
63         ModuleUserIP(InspIRCd* Me)
64                 : Module::Module(Me)
65         {
66                 
67                 mycommand = new cmd_userip(ServerInstance);
68                 ServerInstance->AddCommand(mycommand);
69         }
70
71         void Implements(char* List)
72         {
73                 List[I_On005Numeric] = 1;
74         }
75
76         virtual void On005Numeric(std::string &output)
77         {
78                 output = output + std::string(" USERIP");
79         }
80         
81         virtual ~ModuleUserIP()
82         {
83         }
84         
85         virtual Version GetVersion()
86         {
87                 return Version(1,1,0,1,VF_VENDOR,API_VERSION);
88         }
89         
90 };
91
92 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
93
94 class ModuleUserIPFactory : public ModuleFactory
95 {
96  public:
97         ModuleUserIPFactory()
98         {
99         }
100         
101         ~ModuleUserIPFactory()
102         {
103         }
104         
105         virtual Module * CreateModule(InspIRCd* Me)
106         {
107                 return new ModuleUserIP(Me);
108         }
109         
110 };
111
112
113 extern "C" void * init_module( void )
114 {
115         return new ModuleUserIPFactory;
116 }
117