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 * ---------------------------------------------------
18 #include "modes/cmode_l.h"
20 ModeChannelLimit::ModeChannelLimit() : ModeHandler(NULL, 'l', PARAM_SETONLY, MODETYPE_CHANNEL)
24 ModePair ModeChannelLimit::ModeSet(User*, User*, Channel* channel, const std::string ¶meter)
26 std::string climit = channel->GetModeParameter('l');
29 return std::make_pair(true, climit);
33 return std::make_pair(false, parameter);
37 bool ModeChannelLimit::ResolveModeConflict(std::string &their_param, const std::string &our_param, Channel*)
39 /* When TS is equal, the higher channel limit wins */
40 return (atoi(their_param.c_str()) < atoi(our_param.c_str()));
43 ModeAction ModeChannelLimit::OnModeChange(User*, User*, Channel* channel, std::string ¶meter, bool adding)
47 /* Setting a new limit, sanity check */
48 long limit = atoi(parameter.c_str());
50 /* Wrap low values at 32768 */
54 parameter = ConvToStr(limit);
57 channel->SetModeParam('l', parameter);
59 return MODEACTION_ALLOW;
63 /* Check if theres a limit here to remove.
64 * If there isnt, dont allow the -l
66 if (channel->GetModeParameter('l').empty())
69 return MODEACTION_DENY;
72 /* Removing old limit, no checks here */
73 channel->SetModeParam('l', "");
74 return MODEACTION_ALLOW;