summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2004-05-05 11:27:12 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2004-05-05 11:27:12 +0000
commit176ddfa18c02136904e0ea7c93a8a58d68c2f313 (patch)
tree7d8b26eef1f9d90328f8093f10220647fb57df35 /src
parent4b0c3014f317361ea9fb4cb89b9629bb415c78db (diff)
Added m_redirect, handles +L
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@790 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/modules/m_redirect.cpp97
1 files changed, 97 insertions, 0 deletions
diff --git a/src/modules/m_redirect.cpp b/src/modules/m_redirect.cpp
new file mode 100644
index 000000000..0cdde51c8
--- /dev/null
+++ b/src/modules/m_redirect.cpp
@@ -0,0 +1,97 @@
+#include <stdio.h>
+
+#include "users.h"
+#include "channels.h"
+#include "modules.h"
+
+/* $ModDesc: Provides channel mode +L (limit redirection) */
+
+
+class ModuleRedirect : public Module
+{
+ Server *Srv;
+
+ public:
+
+ ModuleRedirect()
+ {
+ Srv = new Server;
+ Srv->AddExtendedMode('L',MT_CHANNEL,false,1,0);
+ }
+
+ virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list &params)
+ {
+
+ if ((modechar == 'L') && (type == MT_CHANNEL))
+ {
+ chanrec* c = Srv->Findchannel(params[0]);
+ if (c)
+ {
+ if (c->IsCustomModeSet('L'))
+ {
+ WriteServ(user->fd,"690 %s :Circular redirection, mode +L to %s not allowed.",user->nick,params[0].c_str());
+ return 0;
+ }
+ }
+ return 1;
+ }
+ }
+
+ virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname)
+ {
+ if (chan)
+ {
+ if (chan->IsCustomModeSet('L'))
+ {
+ if (chan->limit >= Srv->CountUsers(chan))
+ {
+ char* channel = chan->GetModeParameter('L');
+ WriteServ(user->fd,"470 %s :%s has become full, so you are automatically being transferred to the linked channel %s",user->nick,cname,channel);
+ Srv->JoinUserToChannel(user,channel,"");
+ return 1;
+ }
+ }
+ }
+ }
+
+ virtual ~ModuleRedirect()
+ {
+ delete Srv;
+ }
+
+ virtual Version GetVersion()
+ {
+ return Version(1,0,0,0);
+ }
+
+ virtual void OnUserConnect(userrec* user)
+ {
+ }
+
+};
+
+
+class ModuleRedirectFactory : public ModuleFactory
+{
+ public:
+ ModuleRedirectFactory()
+ {
+ }
+
+ ~ModuleRedirectFactory()
+ {
+ }
+
+ virtual Module * CreateModule()
+ {
+ return new ModuleRedirect;
+ }
+
+};
+
+
+extern "C" void * init_module( void )
+{
+ return new ModuleRedirectFactory;
+}
+