1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2008 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
16 /* $ModDesc: Provides support for channel mode +P to provide permanent channels */
19 /** Handles the +P channel mode
21 class PermChannel : public ModeHandler
24 PermChannel(InspIRCd* Instance) : ModeHandler(Instance, 'P', 0, 0, false, MODETYPE_CHANNEL, false) { }
26 ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding, bool)
30 if (!channel->IsModeSet('P'))
32 channel->SetMode('P',true);
33 return MODEACTION_ALLOW;
38 if (channel->IsModeSet('P'))
40 channel->SetMode('P',false);
42 if (channel->GetUserCounter() == 0)
44 return MODEACTION_ALLOW;
48 return MODEACTION_DENY;
52 class ModulePermanentChannels : public Module
57 ModulePermanentChannels(InspIRCd* Me) : Module(Me)
59 p = new PermChannel(ServerInstance);
60 if (!ServerInstance->Modes->AddMode(p))
63 throw ModuleException("Could not add new modes!");
65 Implementation eventlist[] = { I_OnChannelPreDelete };
66 ServerInstance->Modules->Attach(eventlist, this, 1);
69 virtual ~ModulePermanentChannels()
71 ServerInstance->Modes->DelMode(p);
75 virtual Version GetVersion()
77 return Version(1,2,0,0,VF_COMMON|VF_VENDOR,API_VERSION);
80 virtual int OnChannelPreDelete(Channel *c)
82 if (c->IsModeSet('P'))
89 MODULE_INIT(ModulePermanentChannels)