7 /* $ModDesc: Provides channel mode +L (limit redirection) */
10 class ModuleRedirect : public Module
19 Srv->AddExtendedMode('L',MT_CHANNEL,false,1,0);
22 virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list ¶ms)
24 if ((modechar == 'L') && (type == MT_CHANNEL))
28 std::string ChanToJoin = params[0];
29 chanrec* c = Srv->FindChannel(ChanToJoin);
32 if (c->IsCustomModeSet('L'))
34 WriteServ(user->fd,"690 %s :Circular redirection, mode +L to %s not allowed.",user->nick,params[0].c_str());
43 virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname)
47 if (chan->IsCustomModeSet('L'))
49 if (chan->limit >= Srv->CountUsers(chan))
51 std::string channel = chan->GetModeParameter('L');
52 WriteServ(user->fd,"470 %s :%s has become full, so you are automatically being transferred to the linked channel %s",user->nick,cname,channel.c_str());
53 Srv->JoinUserToChannel(user,channel.c_str(),"");
60 virtual ~ModuleRedirect()
65 virtual Version GetVersion()
67 return Version(1,0,0,0);
70 virtual void OnUserConnect(userrec* user)
77 class ModuleRedirectFactory : public ModuleFactory
80 ModuleRedirectFactory()
84 ~ModuleRedirectFactory()
88 virtual Module * CreateModule()
90 return new ModuleRedirect;
96 extern "C" void * init_module( void )
98 return new ModuleRedirectFactory;