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 * ---------------------------------------------------
17 /* $ModDesc: Sets (and unsets) modes on users when they connect */
19 class ModuleModesOnConnect : public Module
26 ModuleModesOnConnect(InspIRCd* Me)
30 Conf = new ConfigReader(ServerInstance);
33 void Implements(char* List)
35 List[I_OnPostConnect] = List[I_OnRehash] = 1;
38 virtual void OnRehash(userrec* user, const std::string ¶meter)
41 Conf = new ConfigReader(ServerInstance);
44 virtual ~ModuleModesOnConnect()
49 virtual Version GetVersion()
51 return Version(1,1,0,1,VF_VENDOR,API_VERSION);
54 virtual void OnPostConnect(userrec* user)
59 for (int j = 0; j < Conf->Enumerate("connect"); j++)
61 std::string hostn = Conf->ReadValue("connect","allow",j);
62 if ((match(user->GetIPString(),hostn.c_str(),true)) || (match(user->host,hostn.c_str())))
64 std::string ThisModes = Conf->ReadValue("connect","modes",j);
65 if (!ThisModes.empty())
68 stringstream ss(ThisModes);
70 vector<string> tokens;
72 // split ThisUserModes into modes and mode params
74 tokens.push_back(buf);
76 int size = tokens.size() + 1;
77 const char** modes = new const char*[size];
78 modes[0] = user->nick;
79 modes[1] = tokens[0].c_str();
81 if (tokens.size() > 1)
83 // process mode params
85 for (unsigned int k = 1; k < tokens.size(); k++)
87 modes[i] = tokens[k].c_str();
92 ServerInstance->Parser->CallHandler("MODE", modes, size, user);
101 MODULE_INIT(ModuleModesOnConnect)