1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * Inspire is copyright (C) 2002-2004 ChatSpike-Dev.
7 * <brain@chatspike.net>
8 * <Craig@chatspike.net>
10 * Written by Craig Edwards, Craig McLure, and others.
11 * This program is free but copyrighted software; see
12 * the file COPYING for details.
14 * ---------------------------------------------------
22 /* $ModDesc: Provides channel mode +L (limit redirection) */
25 class ModuleRedirect : public Module
34 Srv->AddExtendedMode('L',MT_CHANNEL,false,1,0);
37 virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list ¶ms)
39 if ((modechar == 'L') && (type == MT_CHANNEL))
43 std::string ChanToJoin = params[0];
44 chanrec* c = Srv->FindChannel(ChanToJoin);
47 if (c->IsCustomModeSet('L'))
49 WriteServ(user->fd,"690 %s :Circular redirection, mode +L to %s not allowed.",user->nick,params[0].c_str());
59 virtual void On005Numeric(std::string &output)
61 std::stringstream line(output);
62 std::string temp1, temp2;
66 if (temp1.substr(0,10) == "CHANMODES=")
68 // By doing this we're *assuming* no other module has fucked up the CHANMODES=
69 // section of the 005 numeric. If they have, we're going DOWN in a blaze of glory,
70 // with a honking great EXCEPTION :)
71 temp1.insert(temp1.find(",")+1,"L");
73 temp2 = temp2 + temp1 + " ";
76 output = temp2.substr(0,temp2.length()-1);
79 virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname)
83 if (chan->IsCustomModeSet('L'))
85 if (Srv->CountUsers(chan) >= chan->limit)
87 std::string channel = chan->GetModeParameter('L');
88 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());
89 Srv->JoinUserToChannel(user,channel.c_str(),"");
97 virtual ~ModuleRedirect()
102 virtual Version GetVersion()
104 return Version(1,0,0,0,VF_STATIC|VF_VENDOR);
107 virtual void OnUserConnect(userrec* user)
114 class ModuleRedirectFactory : public ModuleFactory
117 ModuleRedirectFactory()
121 ~ModuleRedirectFactory()
125 virtual Module * CreateModule()
127 return new ModuleRedirect;
133 extern "C" void * init_module( void )
135 return new ModuleRedirectFactory;