From 176ddfa18c02136904e0ea7c93a8a58d68c2f313 Mon Sep 17 00:00:00 2001 From: brain Date: Wed, 5 May 2004 11:27:12 +0000 Subject: Added m_redirect, handles +L git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@790 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_redirect.cpp | 97 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 src/modules/m_redirect.cpp 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 + +#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 ¶ms) + { + + 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; +} + -- cgit v1.2.3