]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_userip.cpp
Fix these to use new hook system (u_listmode wasnt fixed yet)
[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
16 /* $ModDesc: Provides support for USERIP command */
17
18 /** Handle /USERIP
19  */
20 class CommandUserip : public Command
21 {
22  public:
23         CommandUserip (InspIRCd* Instance) : Command(Instance,"USERIP", 'o', 1)
24         {
25                 this->source = "m_userip.so";
26                 syntax = "<nick>{,<nick>}";
27         }
28
29         CmdResult Handle (const char** parameters, int pcnt, User *user)
30         {
31                 std::string retbuf = std::string("340 ") + user->nick + " :";
32
33                 for (int i = 0; i < pcnt; i++)
34                 {
35                         User *u = ServerInstance->FindNick(parameters[i]);
36                         if ((u) && (u->registered == REG_ALL))
37                         {
38                                 retbuf = retbuf + u->nick + (IS_OPER(u) ? "*" : "") + "=+" + u->ident + "@" + u->GetIPString() + " ";
39                         }
40                 }
41
42                 user->WriteServ(retbuf);
43
44                 /* Dont send to the network */
45                 return CMD_LOCALONLY;
46         }
47 };
48
49 class ModuleUserIP : public Module
50 {
51         CommandUserip* mycommand;
52  public:
53         ModuleUserIP(InspIRCd* Me)
54                 : Module(Me)
55         {
56                 
57                 mycommand = new CommandUserip(ServerInstance);
58                 ServerInstance->AddCommand(mycommand);
59                 Implementation eventlist[] = { I_On005Numeric };
60                 ServerInstance->Modules->Attach(eventlist, this, 1);
61         }
62
63         void Implements(char* List)
64         {
65                 List[I_On005Numeric] = 1;
66         }
67
68         virtual void On005Numeric(std::string &output)
69         {
70                 output = output + std::string(" USERIP");
71         }
72         
73         virtual ~ModuleUserIP()
74         {
75         }
76         
77         virtual Version GetVersion()
78         {
79                 return Version(1,1,0,1,VF_VENDOR,API_VERSION);
80         }
81         
82 };
83
84 MODULE_INIT(ModuleUserIP)
85