5 #include "modes/cmode_l.h"
7 ModeChannelLimit::ModeChannelLimit() : ModeHandler('l', 1, 0, false, MODETYPE_CHANNEL, false)
11 std::pair<bool,std::string> 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 ModeAction ModeChannelLimit::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
27 /* Setting a new limit, sanity check */
28 long limit = atoi(parameter.c_str());
30 /* Wrap low values at 32768 */
34 /* If the new limit is the same as the old limit,
35 * and the old limit isnt 0, disallow */
36 if ((limit == channel->limit) && (channel->limit > 0))
39 return MODEACTION_DENY;
42 /* They must have specified an invalid number.
48 return MODEACTION_DENY;
51 parameter = ConvToStr(limit);
54 channel->limit = limit;
55 channel->modes[CM_LIMIT] = 1;
57 return MODEACTION_ALLOW;
61 /* Check if theres a limit here to remove.
62 * If there isnt, dont allow the -l
67 return MODEACTION_DENY;
70 /* Removing old limit, no checks here */
72 channel->modes[CM_LIMIT] = 0;
74 return MODEACTION_ALLOW;
77 return MODEACTION_DENY;