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 * ---------------------------------------------------
23 #include "helperfuncs.h"
25 /* $ModDesc: Provides channel mode +L (limit redirection) */
28 class ModuleRedirect : public Module
37 Srv->AddExtendedMode('L',MT_CHANNEL,false,1,0);
40 virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list ¶ms)
42 if ((modechar == 'L') && (type == MT_CHANNEL))
46 std::string ChanToJoin = params[0];
47 chanrec* c = Srv->FindChannel(ChanToJoin);
50 if (c->IsCustomModeSet('L'))
52 WriteServ(user->fd,"690 %s :Circular redirection, mode +L to %s not allowed.",user->nick,params[0].c_str());
62 virtual void On005Numeric(std::string &output)
64 std::stringstream line(output);
65 std::string temp1, temp2;
69 if (temp1.substr(0,10) == "CHANMODES=")
71 // By doing this we're *assuming* no other module has fucked up the CHANMODES=
72 // section of the 005 numeric. If they have, we're going DOWN in a blaze of glory,
73 // with a honking great EXCEPTION :)
74 temp1.insert(temp1.find(",")+1,"L");
76 temp2 = temp2 + temp1 + " ";
79 output = temp2.substr(0,temp2.length()-1);
82 virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname)
86 if (chan->IsCustomModeSet('L'))
88 if (Srv->CountUsers(chan) >= chan->limit)
90 std::string channel = chan->GetModeParameter('L');
91 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());
92 Srv->JoinUserToChannel(user,channel.c_str(),"");
100 virtual ~ModuleRedirect()
105 virtual Version GetVersion()
107 return Version(1,0,0,0,VF_STATIC|VF_VENDOR);
110 virtual void OnUserConnect(userrec* user)
117 class ModuleRedirectFactory : public ModuleFactory
120 ModuleRedirectFactory()
124 ~ModuleRedirectFactory()
128 virtual Module * CreateModule()
130 return new ModuleRedirect;
136 extern "C" void * init_module( void )
138 return new ModuleRedirectFactory;