Skip to content

Commit

Permalink
Add additional modules for irc.spi.gt
Browse files Browse the repository at this point in the history
  • Loading branch information
md-5 committed Jan 28, 2018
1 parent 53d822a commit a5d44f4
Show file tree
Hide file tree
Showing 4 changed files with 272 additions and 0 deletions.
66 changes: 66 additions & 0 deletions src/modules/m_bansync.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* InspIRCd -- Internet Relay Chat Daemon
*
* Copyright (C) 2015 NickG365 <[email protected]>
*
* 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
* License as published by the Free Software Foundation, version 2.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/* $ModAuthor: NickG365 */
/* $ModAuthorMail: [email protected] */
/* $ModDesc: Implements extban +b J: - check bans from other channels */

#include "inspircd.h"

class ModuleBanSyncExtban : public Module
{
public:
void init()
{
Implementation eventlist[] = { I_OnCheckBan, I_On005Numeric };
ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
}

Version GetVersion()
{
return Version("Extban 'J' - check bans from other channels", VF_OPTCOMMON);
}

ModResult OnCheckBan(User *user, Channel *c, const std::string& mask)
{
static bool recursing = false;

if ((mask.length() > 2) && (mask[0] == 'J') && (mask[1] == ':'))
{
if (recursing)
return MOD_RES_PASSTHRU;
std::string rm = mask.substr(2);
Channel* channel = ServerInstance->FindChan(rm);
if (channel == NULL || channel == c)
return MOD_RES_PASSTHRU;
recursing = true;
if (channel->IsBanned(user))
return MOD_RES_DENY;
recursing = false;
}
return MOD_RES_PASSTHRU;
}

void On005Numeric(std::string &output)
{
ServerInstance->AddExtBanChar('J');
}
};

MODULE_INIT(ModuleBanSyncExtban)

54 changes: 54 additions & 0 deletions src/modules/m_conn_banner.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* InspIRCd -- Internet Relay Chat Daemon
*
* Copyright (C) 2012 Attila Molnar <[email protected]>
*
* 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
* License as published by the Free Software Foundation, version 2.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/* $ModAuthor: Attila Molnar */
/* $ModAuthorMail: [email protected] */
/* $ModDesc: Displays a static text to every connecting user before registration */
/* $ModDepends: core 2.0 */

#include "inspircd.h"

class ModuleConnBanner : public Module
{
std::string text;
public:
void init()
{
OnRehash(NULL);
Implementation eventlist[] = { I_OnRehash, I_OnUserInit };
ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
}

void OnRehash(User* user)
{
text = ServerInstance->Config->ConfValue("connbanner")->getString("text");
}

void OnUserInit(LocalUser* user)
{
if (!text.empty())
user->WriteServ("NOTICE Auth :*** " + text);
}

Version GetVersion()
{
return Version("Displays a static text to every connecting user before registration");
}
};

MODULE_INIT(ModuleConnBanner)
55 changes: 55 additions & 0 deletions src/modules/m_forceident.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* InspIRCd -- Internet Relay Chat Daemon
*
* Copyright (C) 2013 Peter Powell <[email protected]>
*
* 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
* License as published by the Free Software Foundation, version 2.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/


/* $ModAuthor: Peter "SaberUK" Powell */
/* $ModAuthorMail: [email protected] */
/* $ModDesc: Allows forcing idents on users based on their connect class. */
/* $ModDepends: core 2.0 */
/* $ModConfig: <connect forceident="example"> */

#include "inspircd.h"

class ModuleForceIdent : public Module
{
public:
void init()
{
ServerInstance->Modules->Attach(I_OnUserConnect, this);
}

void OnUserConnect(LocalUser* user)
{
ConfigTag* tag = user->MyClass->config;
std::string ident = tag->getString("forceident");
if (ServerInstance->IsIdent(ident.c_str()))
{
ServerInstance->Logs->Log("m_forceident", DEBUG, "Setting ident of user '%s' (%s) in class '%s' to '%s'.",
user->nick.c_str(), user->uuid.c_str(), user->MyClass->name.c_str(), ident.c_str());
user->ident = ident;
user->InvalidateCache();
}
}

Version GetVersion()
{
return Version("Allows forcing idents on users based on their connect class.");
}
};

MODULE_INIT(ModuleForceIdent)
97 changes: 97 additions & 0 deletions src/modules/m_morebans.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*
* InspIRCd -- Internet Relay Chat Daemon
*
* Copyright (C) 2015 NickG365 <[email protected]>
*
* 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
* License as published by the Free Software Foundation, version 2.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/* $ModAuthor: NickG365 */
/* $ModAuthorMail: [email protected] */
/* $ModDesc: Allows increasing the ban list limit for specific channels with channel mode +E (max) */

#include <stdlib.h>
#include "inspircd.h"

class LargeBanListMode : public ModeHandler
{
public:
LargeBanListMode(Module* Creator) : ModeHandler(Creator, "largebanlist", 'E', PARAM_SETONLY, MODETYPE_CHANNEL)
{
oper = true;
}

ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
{
// Removing mode that wasn't set
if (channel->IsModeSet(this) == false && !adding)
return MODEACTION_DENY;
// Removing mode
if (channel->IsModeSet(this) && !adding)
{
ServerInstance->Config->maxbans[channel->name] = ServerInstance->Config->maxbans.count("*") ? ServerInstance->Config->maxbans["*"] : 64;
channel->ResetMaxBans();
return MODEACTION_ALLOW;
}
// Adding or updating mode
long newmax = strtol(parameter.c_str(), NULL, 10);
if (newmax == channel->GetMaxBans() || newmax == (ServerInstance->Config->maxbans.count("*") ? ServerInstance->Config->maxbans["*"] : 64))
return MODEACTION_DENY;
ServerInstance->Config->maxbans[channel->name] = newmax;
channel->ResetMaxBans();
channel->SetModeParam(this, parameter);
return MODEACTION_ALLOW;
}
};

class ModuleLargeBanList : public Module
{
private:
LargeBanListMode mode;
public:
ModuleLargeBanList() : mode(this)
{
}

void init()
{
ServerInstance->Modules->AddService(mode);

Implementation eventlist[] = { I_OnRehash };
ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));

OnRehash(NULL);
}

void OnRehash(User* user)
{
for (chan_hash::iterator i = ServerInstance->chanlist->begin(); i != ServerInstance->chanlist->end(); )
{
Channel* channel = i->second;
++i;
if (channel->IsModeSet('E'))
{
long newmax = strtol(channel->GetModeParameter('E').c_str(), NULL, 10);
ServerInstance->Config->maxbans[channel->name] = newmax;
channel->ResetMaxBans();
}
}
}

Version GetVersion()
{
return Version("Allows increasing the ban list limit for specific channels with channel mode +E (max)");
}
};

MODULE_INIT(ModuleLargeBanList)

0 comments on commit a5d44f4

Please sign in to comment.