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());
44 virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname)
48 if (chan->IsCustomModeSet('L'))
50 if (chan->limit >= Srv->CountUsers(chan))
52 std::string channel = chan->GetModeParameter('L');
53 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());
54 Srv->JoinUserToChannel(user,channel.c_str(),"");
61 virtual ~ModuleRedirect()
66 virtual Version GetVersion()
68 return Version(1,0,0,0);
71 virtual void OnUserConnect(userrec* user)
78 class ModuleRedirectFactory : public ModuleFactory
81 ModuleRedirectFactory()
85 ~ModuleRedirectFactory()
89 virtual Module * CreateModule()
91 return new ModuleRedirect;
97 extern "C" void * init_module( void )
99 return new ModuleRedirectFactory;