1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2009 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
16 /* $ModDesc: Sets (and unsets) modes on users when they connect */
18 class ModuleModesOnConnect : public Module
21 ModuleModesOnConnect() {
22 Implementation eventlist[] = { I_OnUserConnect, I_OnRehash };
23 ServerInstance->Modules->Attach(eventlist, this, 2);
24 // for things like +x on connect, important, otherwise we have to resort to config order (bleh) -- w00t
25 ServerInstance->Modules->SetPriority(this, PRIORITY_FIRST);
29 virtual ~ModuleModesOnConnect()
33 virtual Version GetVersion()
35 return Version("Sets (and unsets) modes on users when they connect", VF_VENDOR);
38 virtual void OnUserConnect(LocalUser* user)
40 // Backup and zero out the disabled usermodes, so that we can override them here.
42 memcpy(save, ServerInstance->Config->DisabledUModes,
43 sizeof(ServerInstance->Config->DisabledUModes));
44 memset(ServerInstance->Config->DisabledUModes, 0, 64);
46 ConfigTag* tag = user->MyClass->config;
47 std::string ThisModes = tag->getString("modes");
48 if (!ThisModes.empty())
51 std::stringstream ss(ThisModes);
53 std::vector<std::string> tokens;
55 // split ThisUserModes into modes and mode params
57 tokens.push_back(buf);
59 std::vector<std::string> modes;
60 modes.push_back(user->nick);
61 modes.push_back(tokens[0]);
63 if (tokens.size() > 1)
65 // process mode params
66 for (unsigned int k = 1; k < tokens.size(); k++)
68 modes.push_back(tokens[k]);
72 ServerInstance->Parser->CallHandler("MODE", modes, user);
75 memcpy(ServerInstance->Config->DisabledUModes, save, 64);
79 MODULE_INIT(ModuleModesOnConnect)