1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2010 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(Module* Creator) : ModeHandler(Creator, "hidechans", 'I', PARAM_NONE, MODETYPE_USER) { }
25 ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding)
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() : hm(this)
55 if (!ServerInstance->Modes->AddMode(&hm))
56 throw ModuleException("Could not add new modes!");
57 Implementation eventlist[] = { I_OnWhoisLine, I_OnRehash };
58 ServerInstance->Modules->Attach(eventlist, this, 2);
62 virtual ~ModuleHideChans()
66 virtual Version GetVersion()
68 return Version("Provides support for hiding channels with user mode +I", VF_VENDOR);
71 virtual void OnRehash(User* user)
74 AffectsOpers = conf.ReadFlag("hidechans", "affectsopers", 0);
77 ModResult OnWhoisLine(User* user, User* dest, int &numeric, std::string &text)
79 /* always show to self */
81 return MOD_RES_PASSTHRU;
83 /* don't touch anything except 319 */
85 return MOD_RES_PASSTHRU;
87 /* don't touch if -I */
88 if (!dest->IsModeSet('I'))
89 return MOD_RES_PASSTHRU;
91 /* if it affects opers, we don't care if they are opered */
95 /* doesn't affect opers, sender is opered */
96 if (user->HasPrivPermission("users/auspex"))
97 return MOD_RES_PASSTHRU;
99 /* user must be opered, boned. */
105 MODULE_INIT(ModuleHideChans)