1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2009 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
16 /* $ModDesc: Provides support for hiding channels with user mode +I */
18 /** Handles user mode +I
20 class HideChans : public ModeHandler
23 HideChans(InspIRCd* Instance) : ModeHandler(Instance, 'I', 0, 0, false, MODETYPE_USER, false) { }
25 ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding, bool)
29 if (!dest->IsModeSet('I'))
31 dest->SetMode('I',true);
32 return MODEACTION_ALLOW;
37 if (dest->IsModeSet('I'))
39 dest->SetMode('I',false);
40 return MODEACTION_ALLOW;
44 return MODEACTION_DENY;
48 class ModuleHideChans : public Module
53 ModuleHideChans(InspIRCd* Me) : Module(Me)
56 hm = new HideChans(ServerInstance);
57 if (!ServerInstance->Modes->AddMode(hm))
58 throw ModuleException("Could not add new modes!");
59 Implementation eventlist[] = { I_OnWhoisLine, I_OnRehash };
60 ServerInstance->Modules->Attach(eventlist, this, 2);
64 virtual ~ModuleHideChans()
66 ServerInstance->Modes->DelMode(hm);
70 virtual Version GetVersion()
72 return Version("$Id$", VF_COMMON | VF_VENDOR, API_VERSION);
75 virtual void OnRehash(User* user)
77 ConfigReader conf(ServerInstance);
78 AffectsOpers = conf.ReadFlag("hidechans", "affectsopers", 0);
81 int OnWhoisLine(User* user, User* dest, int &numeric, std::string &text)
83 /* always show to self */
87 /* don't touch anything except 319 */
91 /* don't touch if -I */
92 if (!dest->IsModeSet('I'))
95 /* if it affects opers, we don't care if they are opered */
99 /* doesn't affect opers, sender is opered */
100 if (user->HasPrivPermission("users/auspex"))
103 /* user must be opered, boned. */
109 MODULE_INIT(ModuleHideChans)