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, Module* Creator) : ModeHandler(Creator, '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(InspIRCd* Me) : Module(Me), hm(Me, 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()
64 ServerInstance->Modes->DelMode(&hm);
67 virtual Version GetVersion()
69 return Version("$Id$", VF_COMMON | VF_VENDOR, API_VERSION);
72 virtual void OnRehash(User* user)
74 ConfigReader conf(ServerInstance);
75 AffectsOpers = conf.ReadFlag("hidechans", "affectsopers", 0);
78 ModResult OnWhoisLine(User* user, User* dest, int &numeric, std::string &text)
80 /* always show to self */
82 return MOD_RES_PASSTHRU;
84 /* don't touch anything except 319 */
86 return MOD_RES_PASSTHRU;
88 /* don't touch if -I */
89 if (!dest->IsModeSet('I'))
90 return MOD_RES_PASSTHRU;
92 /* if it affects opers, we don't care if they are opered */
96 /* doesn't affect opers, sender is opered */
97 if (user->HasPrivPermission("users/auspex"))
98 return MOD_RES_PASSTHRU;
100 /* user must be opered, boned. */
106 MODULE_INIT(ModuleHideChans)