5 #include "modes/cmode_l.h"
7 ModeChannelLimit::ModeChannelLimit() : ModeHandler('l', 1, 0, false, MODETYPE_CHANNEL, false)
11 ModePair ModeChannelLimit::ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string ¶meter)
15 return std::make_pair(true, ConvToStr(channel->limit));
19 return std::make_pair(false, parameter);
23 bool ModeChannelLimit::CheckTimeStamp(time_t theirs, time_t ours, const std::string &their_param, const std::string &our_param, chanrec* channel)
25 /* When TS is equal, the higher channel limit wins */
26 return (atoi(their_param.c_str()) < atoi(our_param.c_str()));
29 ModeAction ModeChannelLimit::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
33 /* Setting a new limit, sanity check */
34 long limit = atoi(parameter.c_str());
36 /* Wrap low values at 32768 */
40 /* If the new limit is the same as the old limit,
41 * and the old limit isnt 0, disallow */
42 if ((limit == channel->limit) && (channel->limit > 0))
45 return MODEACTION_DENY;
48 /* They must have specified an invalid number.
54 return MODEACTION_DENY;
57 parameter = ConvToStr(limit);
60 channel->limit = limit;
61 channel->modes[CM_LIMIT] = 1;
63 return MODEACTION_ALLOW;
67 /* Check if theres a limit here to remove.
68 * If there isnt, dont allow the -l
73 return MODEACTION_DENY;
76 /* Removing old limit, no checks here */
78 channel->modes[CM_LIMIT] = 0;
80 return MODEACTION_ALLOW;
83 return MODEACTION_DENY;