diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-07-08 14:03:05 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-07-08 14:03:05 +0000 |
commit | abe417a8090987f61c27082899fa8771f12bd160 (patch) | |
tree | 1f8182e7873df8acbaa9da534362a259c98553db /src/modes/cmode_k.cpp | |
parent | fd411d067c810b12764085081764744857a215b7 (diff) |
Add chmode +k, cut down includes in use in mode.cpp
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4162 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modes/cmode_k.cpp')
-rw-r--r-- | src/modes/cmode_k.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/modes/cmode_k.cpp b/src/modes/cmode_k.cpp new file mode 100644 index 000000000..9e69ed13b --- /dev/null +++ b/src/modes/cmode_k.cpp @@ -0,0 +1,40 @@ +#include "inspircd.h" +#include "mode.h" +#include "channels.h" +#include "users.h" +#include "modes/cmode_k.h" + +ModeChannelKey::ModeChannelKey() : ModeHandler('k', 1, 1, false, MODETYPE_CHANNEL, false) +{ +} + +ModeAction ModeChannelKey::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding) +{ + if (channel->modes[CM_KEY] != adding) + { + if ((channel->modes[CM_KEY]) && (strcasecmp(parameter.c_str(),channel->key))) + { + /* Key is currently set and the correct key wasnt given */ + return MODEACTION_DENY; + } + else if (!channel->modes[CM_KEY]) + { + /* Key isnt currently set */ + strlcpy(channel->key,parameter.c_str(),32); + channel->modes[CM_KEY] = adding; + return MODEACTION_ALLOW; + } + else if ((channel->modes[CM_KEY]) && (!strcasecmp(parameter.c_str(),channel->key))) + { + /* Key is currently set, and correct key was given */ + *channel->key = 0; + channel->modes[CM_KEY] = adding; + return MODEACTION_ALLOW; + } + return MODEACTION_DENY; + } + else + { + return MODEACTION_DENY; + } +} |