5 #include "modes/cmode_k.h"
7 ModeChannelKey::ModeChannelKey() : ModeHandler('k', 1, 1, false, MODETYPE_CHANNEL, false)
11 ModeAction ModeChannelKey::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
13 if (channel->modes[CM_KEY] != adding)
15 if ((channel->modes[CM_KEY]) && (strcasecmp(parameter.c_str(),channel->key)))
17 /* Key is currently set and the correct key wasnt given */
18 return MODEACTION_DENY;
20 else if (!channel->modes[CM_KEY])
22 /* Key isnt currently set */
23 strlcpy(channel->key,parameter.c_str(),32);
24 channel->modes[CM_KEY] = adding;
25 return MODEACTION_ALLOW;
27 else if ((channel->modes[CM_KEY]) && (!strcasecmp(parameter.c_str(),channel->key)))
29 /* Key is currently set, and correct key was given */
31 channel->modes[CM_KEY] = adding;
32 return MODEACTION_ALLOW;
34 return MODEACTION_DENY;
38 return MODEACTION_DENY;