]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_userip.cpp
14a92e068da8177e12f83cf2b136d637d74ba102
[user/henk/code/inspircd.git] / src / modules / m_userip.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
6  * See: http://wiki.inspircd.org/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(Module* Creator) : Command(Creator,"USERIP", 1)
24         {
25                 flags_needed = 'o'; syntax = "<nick>{,<nick>}";
26         }
27
28         CmdResult Handle (const std::vector<std::string> &parameters, User *user)
29         {
30                 std::string retbuf = std::string("340 ") + user->nick + " :";
31                 int nicks = 0;
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                                 nicks++;
45                         }
46                 }
47
48                 if (nicks != 0)
49                         user->WriteServ(retbuf);
50
51                 /* Dont send to the network */
52                 return CMD_SUCCESS;
53         }
54 };
55
56 class ModuleUserIP : public Module
57 {
58         CommandUserip cmd;
59  public:
60         ModuleUserIP(InspIRCd* Me)
61                 : Module(Me), cmd(this)
62         {
63                 ServerInstance->AddCommand(&cmd);
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("Provides support for USERIP command",VF_VENDOR,API_VERSION);
81         }
82
83 };
84
85 MODULE_INIT(ModuleUserIP)
86