X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_ojoin.cpp;h=bbe3f05bb8b93a33d53ef99e30459ac464b6c03f;hb=46e56dedd37abe33af4e8b970d5b83729dc1ef05;hp=176a0e613e648259b9ea960080e7bf562a4d12b6;hpb=5d474dc9fbd9bd36d0a0a8df93e1ec1e180864d7;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_ojoin.cpp b/src/modules/m_ojoin.cpp index 176a0e613..bbe3f05bb 100644 --- a/src/modules/m_ojoin.cpp +++ b/src/modules/m_ojoin.cpp @@ -83,8 +83,7 @@ class CommandOjoin : public Command modes.push_back(parameters[0]); modes.push_back("+Y"); modes.push_back(user->nick); - ServerInstance->SendMode(modes, ServerInstance->FakeClient); - ServerInstance->PI->SendMode(parameters[0], ServerInstance->Modes->GetLastParseParams(), ServerInstance->Modes->GetLastParseTranslate()); + ServerInstance->SendGlobalMode(modes, ServerInstance->FakeClient); } return CMD_SUCCESS; } @@ -99,7 +98,7 @@ class NetworkPrefix : public ModeHandler { list = true; prefix = NPrefix; - levelrequired = 0xFFFFFFFF; + levelrequired = INT_MAX; m_paramtype = TR_NICK; } @@ -133,71 +132,28 @@ class NetworkPrefix : public ModeHandler } } - User* FindAndVerify(std::string ¶meter, Channel* channel) + unsigned int GetPrefixRank() { - User* theuser = ServerInstance->FindNick(parameter); - if ((!theuser) || (!channel->HasUser(theuser))) - { - parameter.clear(); - return NULL; - } - return theuser; + return NETWORK_VALUE; } - ModeAction HandleChange(User* source, User* theuser, bool adding, Channel* channel, std::string ¶meter) + void RemoveMode(User* user, irc::modestacker* stack) { - Membership* m = channel->GetUser(theuser); - if (m && adding) - { - if (!m->hasMode('Y')) - { - parameter = theuser->nick; - return MODEACTION_ALLOW; - } - } - else if (m && !adding) - { - if (m->hasMode('Y')) - { - parameter = theuser->nick; - return MODEACTION_ALLOW; - } - } - return MODEACTION_DENY; } - unsigned int GetPrefixRank() + ModResult AccessCheck(User* source, Channel* channel, std::string ¶meter, bool adding) { - return NETWORK_VALUE; - } + User* theuser = ServerInstance->FindNick(parameter); + // remove own privs? + if (source == theuser && !adding) + return MOD_RES_ALLOW; - void RemoveMode(User* user, irc::modestacker* stack) - { + return MOD_RES_PASSTHRU; } ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) { - User* theuser = FindAndVerify(parameter, channel); - - if (!theuser) - return MODEACTION_DENY; - - // source is a server, or ulined, we'll let them +-Y the user. - if (source == ServerInstance->FakeClient || - ((source == theuser) && (!adding)) || - (ServerInstance->ULine(source->nick.c_str())) || - (ServerInstance->ULine(source->server)) || - (!IS_LOCAL(source)) - ) - { - return HandleChange(source, theuser, adding, channel, parameter); - } - else - { - // bzzzt, wrong answer! - source->WriteNumeric(482, "%s %s :Only servers may change this mode.", source->nick.c_str(), channel->name.c_str()); - return MODEACTION_DENY; - } + return MODEACTION_ALLOW; } }; @@ -244,27 +200,24 @@ class ModuleOjoin : public Module void OnRehash(User* user) { - ConfigReader Conf; + ConfigTag* Conf = ServerInstance->Config->ConfValue("ojoin"); if (!np) { // This is done on module load only - std::string npre = Conf.ReadValue("ojoin", "prefix", 0); + std::string npre = Conf->getString("prefix"); NPrefix = npre.empty() ? 0 : npre[0]; if (NPrefix && ServerInstance->Modes->FindPrefix(NPrefix)) throw ModuleException("Looks like the +Y prefix you picked for m_ojoin is already in use. Pick another."); } - notice = Conf.ReadFlag("ojoin", "notice", "yes", 0); - op = Conf.ReadFlag("ojoin", "op", "yes", 0); + notice = Conf->getBool("notice", true); + op = Conf->getBool("op", true); } ModResult OnUserPreKick(User* source, Membership* memb, const std::string &reason) { - if ((ServerInstance->ULine(source->nick.c_str())) || ServerInstance->ULine(source->server)) - return MOD_RES_PASSTHRU; - // Don't do anything if they're not +Y if (!memb->hasMode('Y')) return MOD_RES_PASSTHRU;