]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_userip.cpp
Implement feature in bug #395 reported by stealth, and tidy up a bit
[user/henk/code/inspircd.git] / src / modules / m_userip.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
6  * See: http://www.inspircd.org/wiki/index.php/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #include "inspircd.h"
15 #include "users.h"
16 #include "channels.h"
17 #include "modules.h"
18
19 /* $ModDesc: Provides support for USERIP command */
20
21 /** Handle /USERIP
22  */
23 class cmd_userip : public command_t
24 {
25  public:
26         cmd_userip (InspIRCd* Instance) : command_t(Instance,"USERIP", 'o', 1)
27         {
28                 this->source = "m_userip.so";
29                 syntax = "<nick>{,<nick>}";
30         }
31
32         CmdResult Handle (const char** parameters, int pcnt, userrec *user)
33         {
34                 std::string retbuf = std::string("340 ") + user->nick + " :";
35
36                 for (int i = 0; i < pcnt; i++)
37                 {
38                         userrec *u = ServerInstance->FindNick(parameters[i]);
39                         if ((u) && (u->registered == REG_ALL))
40                         {
41                                 retbuf = retbuf + u->nick + (IS_OPER(u) ? "*" : "") + "=+" + u->ident + "@" + u->GetIPString() + " ";
42                         }
43                 }
44
45                 user->WriteServ(retbuf);
46
47                 /* Dont send to the network */
48                 return CMD_LOCALONLY;
49         }
50 };
51
52 class ModuleUserIP : public Module
53 {
54         cmd_userip* mycommand;
55  public:
56         ModuleUserIP(InspIRCd* Me)
57                 : Module(Me)
58         {
59                 
60                 mycommand = new cmd_userip(ServerInstance);
61                 ServerInstance->AddCommand(mycommand);
62         }
63
64         void Implements(char* List)
65         {
66                 List[I_On005Numeric] = 1;
67         }
68
69         virtual void On005Numeric(std::string &output)
70         {
71                 output = output + std::string(" USERIP");
72         }
73         
74         virtual ~ModuleUserIP()
75         {
76         }
77         
78         virtual Version GetVersion()
79         {
80                 return Version(1,1,0,1,VF_VENDOR,API_VERSION);
81         }
82         
83 };
84
85 MODULE_INIT(ModuleUserIP)
86