X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_kicknorejoin.cpp;h=ce95085d85c234a55b19e2ed5750b4a047f16ef4;hb=357d190074ee58809b31ea0c08543566168bddf6;hp=c754aa0f09e967c6c4eff50a81d95190b4d004b3;hpb=1dfead3b2cc9e8c603f6ad6f7216576a2ce361fb;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_kicknorejoin.cpp b/src/modules/m_kicknorejoin.cpp index c754aa0f0..ce95085d8 100644 --- a/src/modules/m_kicknorejoin.cpp +++ b/src/modules/m_kicknorejoin.cpp @@ -25,16 +25,14 @@ #include "inspircd.h" -/* $ModDesc: Provides channel mode +J (delay rejoin after kick) */ - typedef std::map delaylist; /** Handles channel mode +J */ class KickRejoin : public ModeHandler { + static const unsigned int max = 60; public: - unsigned int max; SimpleExtItem ext; KickRejoin(Module* Creator) : ModeHandler(Creator, "kicknorejoin", 'J', PARAM_SETONLY, MODETYPE_CHANNEL) @@ -42,7 +40,7 @@ class KickRejoin : public ModeHandler { } - ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string& parameter, bool adding) + ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string& parameter, bool adding) CXX11_OVERRIDE { if (adding) { @@ -56,7 +54,6 @@ class KickRejoin : public ModeHandler v = max; parameter = ConvToStr(v); - channel->SetModeParam(this, parameter); } else { @@ -64,7 +61,6 @@ class KickRejoin : public ModeHandler return MODEACTION_DENY; ext.unset(channel); - channel->SetModeParam(this, ""); } return MODEACTION_ALLOW; } @@ -75,29 +71,12 @@ class ModuleKickNoRejoin : public Module KickRejoin kr; public: - ModuleKickNoRejoin() : kr(this) { } - void init() - { - ServerInstance->Modules->AddService(kr); - ServerInstance->Modules->AddService(kr.ext); - Implementation eventlist[] = { I_OnUserPreJoin, I_OnUserKick, I_OnRehash }; - ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); - OnRehash(NULL); - } - - void OnRehash(User* user) - { - kr.max = ServerInstance->Duration(ServerInstance->Config->ConfValue("kicknorejoin")->getString("maxtime")); - if (!kr.max) - kr.max = 30*60; - } - - ModResult OnUserPreJoin(User* user, Channel* chan, const char* cname, std::string &privs, const std::string &keygiven) + ModResult OnUserPreJoin(LocalUser* user, Channel* chan, const std::string& cname, std::string& privs, const std::string& keygiven) CXX11_OVERRIDE { if (chan) { @@ -111,8 +90,8 @@ public: if (iter->first == user->uuid) { std::string modeparam = chan->GetModeParameter(&kr); - user->WriteNumeric(ERR_DELAYREJOIN, "%s %s :You must wait %s seconds after being kicked to rejoin (+J)", - user->nick.c_str(), chan->name.c_str(), modeparam.c_str()); + user->WriteNumeric(ERR_DELAYREJOIN, "%s :You must wait %s seconds after being kicked to rejoin (+J)", + chan->name.c_str(), modeparam.c_str()); return MOD_RES_DENY; } ++iter; @@ -124,14 +103,14 @@ public: } } - if (!dl->size()) + if (dl->empty()) kr.ext.unset(chan); } } return MOD_RES_PASSTHRU; } - void OnUserKick(User* source, Membership* memb, const std::string &reason, CUList& excepts) + void OnUserKick(User* source, Membership* memb, const std::string &reason, CUList& excepts) CXX11_OVERRIDE { if (memb->chan->IsModeSet(&kr) && (IS_LOCAL(memb->user)) && (source != memb->user)) { @@ -145,15 +124,10 @@ public: } } - ~ModuleKickNoRejoin() - { - } - - Version GetVersion() + Version GetVersion() CXX11_OVERRIDE { return Version("Channel mode to delay rejoin after kick", VF_VENDOR); } }; - MODULE_INIT(ModuleKickNoRejoin)