]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_maphide.cpp
9a46df1d4f83179fddbeda1537a0cc452f55ed52
[user/henk/code/inspircd.git] / src / modules / m_maphide.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: Hide /MAP and /LINKS in the same form as ircu (mostly useless) */
17
18 class ModuleMapHide : public Module
19 {
20         std::string url;
21  public:
22         ModuleMapHide(InspIRCd* Me)
23                 : Module(Me)
24         {
25                 ServerInstance->Modules->Attach(I_OnPreCommand, this);
26                 ServerInstance->Modules->Attach(I_OnRehash, this);
27                 OnRehash(NULL);
28         }
29
30         void OnRehash(User* user)
31         {
32                 ConfigReader MyConf(ServerInstance);
33                 url = MyConf.ReadValue("security", "maphide", 0);
34         }
35
36         ModResult OnPreCommand(std::string &command, std::vector<std::string> &parameters, User *user, bool validated, const std::string &original_line)
37         {
38                 if (!IS_OPER(user) && !url.empty() && (command == "MAP" || command == "LINKS"))
39                 {
40                         user->WriteServ("NOTICE %s :/%s has been disabled; visit %s", user->nick.c_str(), command.c_str(), url.c_str());
41                         return MOD_RES_DENY;
42                 }
43                 else
44                         return MOD_RES_PASSTHRU;
45         }
46
47         virtual ~ModuleMapHide()
48         {
49         }
50
51         virtual Version GetVersion()
52         {
53                 return Version("Hide /MAP and /LINKS in the same form as ircu (mostly useless)", VF_VENDOR, API_VERSION);
54         }
55 };
56
57 MODULE_INIT(ModuleMapHide)
58