summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/modes/cmode_i.h8
-rw-r--r--src/mode.cpp3
-rw-r--r--src/modes/cmode_i.cpp22
3 files changed, 33 insertions, 0 deletions
diff --git a/include/modes/cmode_i.h b/include/modes/cmode_i.h
new file mode 100644
index 000000000..7320cb169
--- /dev/null
+++ b/include/modes/cmode_i.h
@@ -0,0 +1,8 @@
+#include "mode.h"
+
+class ModeChannelInviteOnly : public ModeHandler
+{
+ public:
+ ModeChannelInviteOnly();
+ ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding);
+};
diff --git a/src/mode.cpp b/src/mode.cpp
index 3c6f9d7f0..6da0dbcb6 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -54,6 +54,8 @@ using namespace std;
#include "modes/cmode_t.h"
/* +n (no external messages) */
#include "modes/cmode_n.h"
+/* +i (invite only) */
+#include "modes/cmode_i.h"
extern int MODCOUNT;
extern std::vector<Module*> modules;
@@ -652,5 +654,6 @@ ModeParser::ModeParser()
this->AddMode(new ModeChannelModerated, 'm');
this->AddMode(new ModeChannelTopicOps, 't');
this->AddMode(new ModeChannelNoExternal, 'n');
+ this->AddMode(new ModeChannelInviteOnly, 'i');
}
diff --git a/src/modes/cmode_i.cpp b/src/modes/cmode_i.cpp
new file mode 100644
index 000000000..d74ac86e7
--- /dev/null
+++ b/src/modes/cmode_i.cpp
@@ -0,0 +1,22 @@
+#include "inspircd.h"
+#include "mode.h"
+#include "channels.h"
+#include "users.h"
+#include "modes/cmode_i.h"
+
+ModeChannelInviteOnly::ModeChannelInviteOnly() : ModeHandler('i', 0, 0, false, MODETYPE_CHANNEL, false)
+{
+}
+
+ModeAction ModeChannelInviteOnly::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
+{
+ if (channel->modes[CM_INVITEONLY] != adding)
+ {
+ channel->modes[CM_INVITEONLY] = adding;
+ return MODEACTION_ALLOW;
+ }
+ else
+ {
+ return MODEACTION_DENY;
+ }
+}