]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_uhnames.cpp
Remove InspIRCd* parameters and fields
[user/henk/code/inspircd.git] / src / modules / m_uhnames.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 #include "m_cap.h"
16
17 /* $ModDesc: Provides the UHNAMES facility. */
18
19 class ModuleUHNames : public Module
20 {
21  public:
22         GenericCap cap;
23
24         ModuleUHNames() : cap(this, "userhost-in-names")
25         {
26                 Implementation eventlist[] = { I_OnEvent, I_OnPreCommand, I_OnNamesListItem, I_On005Numeric };
27                 ServerInstance->Modules->Attach(eventlist, this, 4);
28         }
29
30         ~ModuleUHNames()
31         {
32         }
33
34         Version GetVersion()
35         {
36                 return Version("Provides the UHNAMES facility.",VF_VENDOR,API_VERSION);
37         }
38
39         void On005Numeric(std::string &output)
40         {
41                 output.append(" UHNAMES");
42         }
43
44         ModResult OnPreCommand(std::string &command, std::vector<std::string> &parameters, User *user, bool validated, const std::string &original_line)
45         {
46                 irc::string c = command.c_str();
47                 /* We don't actually create a proper command handler class for PROTOCTL,
48                  * because other modules might want to have PROTOCTL hooks too.
49                  * Therefore, we just hook its as an unvalidated command therefore we
50                  * can capture it even if it doesnt exist! :-)
51                  */
52                 if (c == "PROTOCTL")
53                 {
54                         if ((parameters.size()) && (!strcasecmp(parameters[0].c_str(),"UHNAMES")))
55                         {
56                                 cap.ext.set(user, 1);
57                                 return MOD_RES_DENY;
58                         }
59                 }
60                 return MOD_RES_PASSTHRU;
61         }
62
63         void OnNamesListItem(User* issuer, Membership* memb, std::string &prefixes, std::string &nick)
64         {
65                 if (!cap.ext.get(issuer))
66                         return;
67
68                 if (nick.empty())
69                         return;
70
71                 nick = memb->user->GetFullHost();
72         }
73
74         void OnEvent(Event* ev)
75         {
76                 cap.HandleEvent(ev);
77         }
78 };
79
80 MODULE_INIT(ModuleUHNames)