]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_userip.cpp
77f3474f936d9c16083c5b0ae26327df7ef234e8
[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) ? "*" : "") + "=";
39                                 if (IS_AWAY(u))
40                                         retbuf += "-";
41                                 else
42                                         retbuf += "+";
43                                 retbuf += u->ident + "@" + u->GetIPString() + " ";
44                         }
45                 }
46
47                 user->WriteServ(retbuf);
48
49                 /* Dont send to the network */
50                 return CMD_LOCALONLY;
51         }
52 };
53
54 class ModuleUserIP : public Module
55 {
56         CommandUserip* mycommand;
57  public:
58         ModuleUserIP(InspIRCd* Me)
59                 : Module(Me)
60         {
61
62                 mycommand = new CommandUserip(ServerInstance);
63                 ServerInstance->AddCommand(mycommand);
64                 Implementation eventlist[] = { I_On005Numeric };
65                 ServerInstance->Modules->Attach(eventlist, this, 1);
66         }
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("$Id$",VF_VENDOR,API_VERSION);
81         }
82
83 };
84
85 MODULE_INIT(ModuleUserIP)
86