]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_kicknorejoin.cpp
Sync helpop chmodes s and p with docs
[user/henk/code/inspircd.git] / src / modules / m_kicknorejoin.cpp
index 67711f7665b8e60e381d6ff1c2f911839c0e4ed1..e14530a92c889750860043d1cb00ecf0bcc58910 100644 (file)
@@ -1,13 +1,16 @@
 /*
  * InspIRCd -- Internet Relay Chat Daemon
  *
+ *   Copyright (C) 2018 A_D <A-UNDERSCORE-D@users.noreply.github.com>
+ *   Copyright (C) 2014 Daniel Vassdal <shutter@canternet.org>
+ *   Copyright (C) 2013, 2017-2020 Sadie Powell <sadie@witchery.services>
+ *   Copyright (C) 2012-2015 Attila Molnar <attilamolnar@hush.com>
+ *   Copyright (C) 2012, 2019 Robby <robby@chatbelgie.be>
+ *   Copyright (C) 2009 Uli Schlachter <psychon@inspircd.org>
  *   Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
- *   Copyright (C) 2008 Pippijn van Steenhoven <pip88nl@gmail.com>
  *   Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
- *   Copyright (C) 2006-2007 Robin Burchell <robin+git@viroteck.net>
- *   Copyright (C) 2006 John Brooks <john.brooks@dereferenced.net>
- *   Copyright (C) 2006 Craig Edwards <craigedwards@brainbox.cc>
- *   Copyright (C) 2006 Oliver Lupton <oliverlupton@gmail.com>
+ *   Copyright (C) 2006, 2010 Craig Edwards <brain@inspircd.org>
+ *   Copyright (C) 2006 Oliver Lupton <om@inspircd.org>
  *
  * This file is part of InspIRCd.  InspIRCd is free software: you can
  * redistribute it and/or modify it under the terms of the GNU General Public
 
 
 #include "inspircd.h"
+#include "modules/invite.h"
+
+enum
+{
+       // From RFC 2182.
+       ERR_UNAVAILRESOURCE = 437
+};
+
 
 class KickRejoinData
 {
@@ -89,18 +100,19 @@ class KickRejoin : public ParamMode<KickRejoin, SimpleExtItem<KickRejoinData> >
                : ParamMode<KickRejoin, SimpleExtItem<KickRejoinData> >(Creator, "kicknorejoin", 'J')
                , max(60)
        {
+               syntax = "<seconds>";
        }
 
        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));
@@ -121,10 +133,12 @@ class KickRejoin : public ParamMode<KickRejoin, SimpleExtItem<KickRejoinData> >
 class ModuleKickNoRejoin : public Module
 {
        KickRejoin kr;
+       Invite::API invapi;
 
 public:
        ModuleKickNoRejoin()
                : kr(this)
+               , invapi(this)
        {
        }
 
@@ -133,9 +147,9 @@ public:
                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, chan, InspIRCd::Format("You must wait %u seconds after being kicked to rejoin (+J)", data->delay));
+                               user->WriteNumeric(ERR_UNAVAILRESOURCE, chan->name, InspIRCd::Format("You must wait %u seconds after being kicked to rejoin (+J is set)", data->delay));
                                return MOD_RES_DENY;
                        }
                }
@@ -156,7 +170,7 @@ public:
 
        Version GetVersion() CXX11_OVERRIDE
        {
-               return Version("Channel mode to delay rejoin after kick", VF_VENDOR | VF_COMMON, kr.GetModuleSettings());
+               return Version("Adds channel mode J (kicknorejoin) which prevents users from rejoining after being kicked from a channel.", VF_VENDOR | VF_COMMON, kr.GetModuleSettings());
        }
 };