]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_userip.cpp
Remove unneeded ProtocolInterface::Introduce
[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 (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                 int nicks = 0;
33
34                 for (int i = 0; i < (int)parameters.size(); i++)
35                 {
36                         User *u = ServerInstance->FindNick(parameters[i]);
37                         if ((u) && (u->registered == REG_ALL))
38                         {
39                                 retbuf = retbuf + u->nick + (IS_OPER(u) ? "*" : "") + "=";
40                                 if (IS_AWAY(u))
41                                         retbuf += "-";
42                                 else
43                                         retbuf += "+";
44                                 retbuf += u->ident + "@" + u->GetIPString() + " ";
45                                 nicks++;
46                         }
47                 }
48
49                 if (nicks != 0)
50                         user->WriteServ(retbuf);
51
52                 /* Dont send to the network */
53                 return CMD_LOCALONLY;
54         }
55 };
56
57 class ModuleUserIP : public Module
58 {
59         CommandUserip cmd;
60  public:
61         ModuleUserIP(InspIRCd* Me)
62                 : Module(Me), cmd(Me)
63         {
64                 ServerInstance->AddCommand(&cmd);
65                 Implementation eventlist[] = { I_On005Numeric };
66                 ServerInstance->Modules->Attach(eventlist, this, 1);
67         }
68
69
70         virtual void On005Numeric(std::string &output)
71         {
72                 output = output + std::string(" USERIP");
73         }
74
75         virtual ~ModuleUserIP()
76         {
77         }
78
79         virtual Version GetVersion()
80         {
81                 return Version("$Id$",VF_VENDOR,API_VERSION);
82         }
83
84 };
85
86 MODULE_INIT(ModuleUserIP)
87