+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * InspIRCd: (C) 2002-2007 InspIRCd Development Team
+ * See: http://www.inspircd.org/wiki/index.php/Credits
+ *
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
#include <time.h>
#include <map>
#include <vector>
{
// Taking the mode off, we need to clean up.
delaylist* dl;
-
+
if (channel->GetExt("norejoinusers", dl))
{
DELETE(dl);
channel->Shrink("norejoinusers");
}
+
+ if (!channel->IsModeSet('J'))
+ {
+ return MODEACTION_DENY;
+ }
+ else
+ {
+ channel->SetMode('J', false);
+ return MODEACTION_ALLOW;
+ }
}
- if ((!adding) || (atoi(parameter.c_str()) > 0))
+ else if (atoi(parameter.c_str()) > 0)
{
- ServerInstance->Log(DEBUG,"Got parameter: '%s'",parameter.c_str());
-
if (!channel->IsModeSet('J'))
{
parameter = ConvToStr(atoi(parameter.c_str()));
{
kr = new KickRejoin(ServerInstance);
- ServerInstance->AddMode(kr, 'J');
+ if (!ServerInstance->AddMode(kr, 'J'))
+ throw ModuleException("Could not add new modes!");
}
- virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname)
+ virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname, std::string &privs)
{
if (chan)
{
delaylist* dl;
if (chan->GetExt("norejoinusers", dl))
{
- ServerInstance->Log(DEBUG, "m_kicknorejoin.so: got delay list, iterating over it");
std::vector<userrec*> itemstoremove;
for (delaylist::iterator iter = dl->begin(); iter != dl->end(); iter++)
{
- ServerInstance->Log(DEBUG, "m_kicknorejoin.so:\t[%s] => %d", iter->first->nick, iter->second);
if (iter->second > time(NULL))
{
- ServerInstance->Log(DEBUG, "m_kicknorejoin.so: still inside time slot");
if (iter->first == user)
{
- ServerInstance->Log(DEBUG, "m_kicknorejoin.so: and we have the right user");
user->WriteServ( "495 %s %s :You cannot rejoin this channel yet after being kicked (+J)", user->nick, chan->name);
return 1;
}
else
{
// Expired record, remove.
- ServerInstance->Log(DEBUG, "m_kicknorejoin.so: record expired");
itemstoremove.push_back(iter->first);
}
}
dl = new delaylist;
chan->Extend("norejoinusers", dl);
}
-
- ServerInstance->Log(DEBUG, "m_kicknorejoin.so: setting record for %s, %d second delay", user->nick, strtoint(chan->GetModeParameter('J')));
(*dl)[user] = time(NULL) + strtoint(chan->GetModeParameter('J'));
}
}
virtual Version GetVersion()
{
- return Version(1, 0, 0, 0, VF_COMMON | VF_VENDOR);
+ return Version(1, 1, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
}
};