1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2007 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
22 /* $ModDesc: Sets (and unsets) modes on users when they connect */
24 class ModuleModesOnConnect : public Module
31 ModuleModesOnConnect(InspIRCd* Me)
35 Conf = new ConfigReader(ServerInstance);
38 void Implements(char* List)
40 List[I_OnPostConnect] = List[I_OnRehash] = 1;
43 virtual void OnRehash(userrec* user, const std::string ¶meter)
46 Conf = new ConfigReader(ServerInstance);
49 virtual ~ModuleModesOnConnect()
54 virtual Version GetVersion()
56 return Version(1,1,0,1,VF_VENDOR,API_VERSION);
59 virtual void OnPostConnect(userrec* user)
64 for (int j = 0; j < Conf->Enumerate("connect"); j++)
66 std::string hostn = Conf->ReadValue("connect","allow",j);
67 if ((match(user->GetIPString(),hostn.c_str(),true)) || (match(user->host,hostn.c_str())))
69 std::string ThisModes = Conf->ReadValue("connect","modes",j);
73 stringstream ss(ThisModes);
75 vector<string> tokens;
77 // split ThisUserModes into modes and mode params
79 tokens.push_back(buf);
81 int size = tokens.size() + 1;
82 const char* modes[size];
83 modes[0] = user->nick;
84 modes[1] = tokens[0].c_str();
86 if (tokens.size() > 1)
88 // process mode params
90 for (unsigned int k = 1; k < tokens.size(); k++)
92 modes[i] = tokens[k].c_str();
97 ServerInstance->Parser->CallHandler("MODE", modes, size, user);
105 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
107 class ModuleModesOnConnectFactory : public ModuleFactory
110 ModuleModesOnConnectFactory()
114 ~ModuleModesOnConnectFactory()
118 virtual Module * CreateModule(InspIRCd* Me)
120 return new ModuleModesOnConnect(Me);
126 extern "C" void * init_module( void )
128 return new ModuleModesOnConnectFactory;