#include "inspircd.h"
+#include "modules/invite.h"
+
+enum
+{
+ // From RFC 2182.
+ ERR_UNAVAILRESOURCE = 437
+};
+
class KickRejoinData
{
*/
class KickRejoin : public ParamMode<KickRejoin, SimpleExtItem<KickRejoinData> >
{
- static const unsigned int max = 60;
+ const unsigned int max;
public:
KickRejoin(Module* Creator)
: ParamMode<KickRejoin, SimpleExtItem<KickRejoinData> >(Creator, "kicknorejoin", 'J')
+ , max(60)
{
+ syntax = "<seconds>";
}
- ModeAction OnSet(User* source, Channel* channel, std::string& parameter)
+ ModeAction OnSet(User* source, Channel* channel, std::string& parameter) CXX11_OVERRIDE
{
- int v = ConvToInt(parameter);
+ unsigned int v = ConvToNum<unsigned int>(parameter);
if (v <= 0)
+ {
+ source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter));
return MODEACTION_DENY;
+ }
- if ((IS_LOCAL(source) && ((unsigned int)v > max)))
+ if (IS_LOCAL(source) && v > max)
v = max;
ext.set(channel, new KickRejoinData(v));
{
out.append(ConvToStr(krd->delay));
}
+
+ std::string GetModuleSettings() const
+ {
+ return ConvToStr(max);
+ }
};
class ModuleKickNoRejoin : public Module
{
KickRejoin kr;
+ Invite::API invapi;
public:
ModuleKickNoRejoin()
: kr(this)
+ , invapi(this)
{
}
if (chan)
{
const KickRejoinData* data = kr.ext.get(chan);
- if ((data) && (!data->canjoin(user)))
+ if ((data) && !invapi->IsInvited(user, chan) && (!data->canjoin(user)))
{
- user->WriteNumeric(ERR_DELAYREJOIN, "%s :You must wait %u seconds after being kicked to rejoin (+J)", chan->name.c_str(), data->delay);
+ user->WriteNumeric(ERR_UNAVAILRESOURCE, chan, InspIRCd::Format("You must wait %u seconds after being kicked to rejoin (+J is set)", data->delay));
return MOD_RES_DENY;
}
}
Version GetVersion() CXX11_OVERRIDE
{
- return Version("Channel mode to delay rejoin after kick", VF_VENDOR);
+ return Version("Provides channel mode +J, delays rejoins after kicks", VF_VENDOR | VF_COMMON, kr.GetModuleSettings());
}
};