]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_userip.cpp
fixed some indentation and spacing in modules
[user/henk/code/inspircd.git] / src / modules / m_userip.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2008 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 std::vector<std::string> &parameters, User *user)
30         {
31                 std::string retbuf = std::string("340 ") + user->nick + " :";
32
33                 for (int i = 0; i < (int)parameters.size(); 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
64         virtual void On005Numeric(std::string &output)
65         {
66                 output = output + std::string(" USERIP");
67         }
68
69         virtual ~ModuleUserIP()
70         {
71         }
72
73         virtual Version GetVersion()
74         {
75                 return Version(1,2,0,1,VF_VENDOR,API_VERSION);
76         }
77
78 };
79
80 MODULE_INIT(ModuleUserIP)
81