1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2007 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 * ---------------------------------------------------
18 #include "modes/cmode_l.h"
20 ModeChannelLimit::ModeChannelLimit(InspIRCd* Instance) : ModeHandler(Instance, 'l', 1, 0, false, MODETYPE_CHANNEL, false)
24 ModePair ModeChannelLimit::ModeSet(User* source, User* dest, Channel* channel, const std::string ¶meter)
28 return std::make_pair(true, ConvToStr(channel->limit));
32 return std::make_pair(false, parameter);
36 bool ModeChannelLimit::CheckTimeStamp(time_t theirs, time_t ours, const std::string &their_param, const std::string &our_param, Channel* channel)
38 /* When TS is equal, the higher channel limit wins */
39 return (atoi(their_param.c_str()) < atoi(our_param.c_str()));
42 ModeAction ModeChannelLimit::OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding)
46 /* Setting a new limit, sanity check */
47 long limit = atoi(parameter.c_str());
49 /* Wrap low values at 32768 */
53 /* If the new limit is the same as the old limit,
54 * and the old limit isnt 0, disallow */
55 if ((limit == channel->limit) && (channel->limit > 0))
58 return MODEACTION_DENY;
61 /* They must have specified an invalid number.
67 return MODEACTION_DENY;
70 parameter = ConvToStr(limit);
73 channel->limit = limit;
74 channel->modes[CM_LIMIT] = 1;
76 return MODEACTION_ALLOW;
80 /* Check if theres a limit here to remove.
81 * If there isnt, dont allow the -l
86 return MODEACTION_DENY;
89 /* Removing old limit, no checks here */
91 channel->modes[CM_LIMIT] = 0;
93 return MODEACTION_ALLOW;
96 return MODEACTION_DENY;