1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2010 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 * ---------------------------------------------------
15 #include "u_listmode.h"
17 /* $ModDesc: Provides support for the +w channel mode, autoop list */
19 /** Handles +w channel mode
21 class AutoOpList : public ListModeBase
24 AutoOpList(Module* Creator) : ListModeBase(Creator, "autoop", 'w', "End of Channel Access List", 910, 911, true)
26 levelrequired = OP_VALUE;
29 ModResult AccessCheck(User* source, Channel* channel, std::string ¶meter, bool adding)
31 std::string::size_type pos = parameter.find(':');
32 if (pos == 0 || pos == std::string::npos)
33 return adding ? MOD_RES_DENY : MOD_RES_PASSTHRU;
34 unsigned int mylevel = channel->GetPrefixValue(source);
38 ModeHandler* mh = ServerInstance->Modes->FindMode(parameter[pos], MODETYPE_CHANNEL);
39 if (adding && (!mh || !mh->GetPrefixRank()))
41 source->WriteNumeric(415, "%s %c :Cannot find prefix mode '%c' for autoop",
42 source->nick.c_str(), parameter[pos], parameter[pos]);
49 if (mh->AccessCheck(source, channel, dummy, true) == MOD_RES_DENY)
51 if (mh->GetLevelRequired() > mylevel)
53 source->WriteNumeric(482, "%s %s :You must be able to set mode '%c' to include it in an autoop",
54 source->nick.c_str(), channel->name.c_str(), parameter[pos]);
58 return MOD_RES_PASSTHRU;
63 class ModuleAutoOp : public Module
68 ModuleAutoOp() : mh(this)
70 ServerInstance->Modules->AddService(mh);
71 mh.DoImplements(this);
73 Implementation list[] = { I_OnUserPreJoin, };
74 ServerInstance->Modules->Attach(list, this, 1);
77 ModResult OnUserPreJoin(User *user, Channel *chan, const char *cname, std::string &privs, const std::string &keygiven)
80 return MOD_RES_PASSTHRU;
82 modelist* list = mh.extItem.get(chan);
85 for (modelist::iterator it = list->begin(); it != list->end(); it++)
87 std::string::size_type colon = it->mask.find(':');
88 if (colon == std::string::npos)
90 if (chan->CheckBan(user, it->mask.substr(colon+1)))
91 privs += it->mask.substr(0, colon);
95 return MOD_RES_PASSTHRU;
98 void OnCleanup(int target_type, void* item)
100 mh.DoCleanup(target_type, item);
103 void OnSyncChannel(Channel* chan, Module* proto, void* opaque)
105 mh.DoSyncChannel(chan, proto, opaque);
108 void OnRehash(User* user)
115 return Version("Provides support for the +w channel mode", VF_VENDOR);
119 MODULE_INIT(ModuleAutoOp)