1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2008 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);
31 Implementation eventlist[] = { I_OnPostConnect, I_OnRehash };
32 ServerInstance->Modules->Attach(eventlist, this, 2);
36 virtual void OnRehash(User* user, const std::string ¶meter)
39 Conf = new ConfigReader(ServerInstance);
42 virtual ~ModuleModesOnConnect()
47 virtual Version GetVersion()
49 return Version(1,2,0,1,VF_VENDOR,API_VERSION);
52 virtual void OnPostConnect(User* user)
57 for (int j = 0; j < Conf->Enumerate("connect"); j++)
59 std::string hostn = Conf->ReadValue("connect","allow",j);
60 if ((match(user->GetIPString(),hostn.c_str(),true)) || (match(user->host,hostn.c_str())))
62 std::string ThisModes = Conf->ReadValue("connect","modes",j);
63 if (!ThisModes.empty())
66 std::stringstream ss(ThisModes);
68 std::vector<std::string> tokens;
70 // split ThisUserModes into modes and mode params
72 tokens.push_back(buf);
74 std::vector<std::string> modes;
75 modes.push_back(user->nick);
76 modes.push_back(tokens[0]);
78 if (tokens.size() > 1)
80 // process mode params
81 for (unsigned int k = 1; k < tokens.size(); k++)
83 modes.push_back(tokens[k]);
87 ServerInstance->Parser->CallHandler("MODE", modes, user);
95 MODULE_INIT(ModuleModesOnConnect)