mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-09 10:39:02 -04:00
Split out channel and user mode +r into a separate module.
This commit is contained in:
parent
4dfb70a936
commit
fbed3eca25
@ -2052,16 +2052,23 @@
|
||||
# This module implements the 'identified' state via account names,
|
||||
# and is similar in operation to the way asuka and ircu handle services.
|
||||
#
|
||||
# At the same time, this offers +r for users and channels to mark them
|
||||
# as identified separately from the idea of a master account, which
|
||||
# can be useful for services which are heavily nick-as-account centric.
|
||||
#
|
||||
# Also of note is that this module implements two extbans:
|
||||
# +b R: (stop matching account names from joining)
|
||||
# +b U:n!u@h (blocks matching unregistered users)
|
||||
#
|
||||
#<module name="services_account">
|
||||
|
||||
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
|
||||
# Services integration module: Adds various features which enable
|
||||
# integrating with a third-party services pseudoserver like Anope or
|
||||
# Atheme.
|
||||
#<module name="services">
|
||||
#
|
||||
# If your services server has support for InspIRCd v4 then you can disable
|
||||
# the legacy modes that were previously used for marking a user or channel
|
||||
# as being registered:
|
||||
# <services disablemodes="yes">
|
||||
|
||||
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
|
||||
# Sethost module: Adds the /SETHOST command.
|
||||
# This module is oper-only.
|
||||
|
94
src/modules/m_services.cpp
Normal file
94
src/modules/m_services.cpp
Normal file
@ -0,0 +1,94 @@
|
||||
/*
|
||||
* InspIRCd -- Internet Relay Chat Daemon
|
||||
*
|
||||
* Copyright (C) 2022 Sadie Powell <sadie@witchery.services>
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "inspircd.h"
|
||||
#include "modules/account.h"
|
||||
|
||||
class RegisteredChannel final
|
||||
: public SimpleChannelMode
|
||||
{
|
||||
public:
|
||||
RegisteredChannel(Module* Creator)
|
||||
: SimpleChannelMode(Creator, "c_registered", 'r')
|
||||
{
|
||||
if (ServerInstance->Config->ConfValue("services")->getBool("disablemodes"))
|
||||
DisableAutoRegister();
|
||||
}
|
||||
|
||||
ModeAction OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override
|
||||
{
|
||||
if (IS_LOCAL(source))
|
||||
{
|
||||
source->WriteNumeric(ERR_NOPRIVILEGES, "Only a server may modify the +r channel mode");
|
||||
return MODEACTION_DENY;
|
||||
}
|
||||
|
||||
return SimpleChannelMode::OnModeChange(source, dest, channel, change);
|
||||
}
|
||||
};
|
||||
|
||||
class RegisteredUser final
|
||||
: public SimpleUserMode
|
||||
{
|
||||
|
||||
public:
|
||||
RegisteredUser(Module* Creator)
|
||||
: SimpleUserMode(Creator, "u_registered", 'r')
|
||||
{
|
||||
if (ServerInstance->Config->ConfValue("services")->getBool("disablemodes"))
|
||||
DisableAutoRegister();
|
||||
}
|
||||
|
||||
ModeAction OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override
|
||||
{
|
||||
if (IS_LOCAL(source))
|
||||
{
|
||||
source->WriteNumeric(ERR_NOPRIVILEGES, "Only a server may modify the +r user mode");
|
||||
return MODEACTION_DENY;
|
||||
}
|
||||
|
||||
return SimpleUserMode::OnModeChange(source, dest, channel, change);
|
||||
}
|
||||
};
|
||||
|
||||
class ModuleServices final
|
||||
: public Module
|
||||
{
|
||||
private:
|
||||
Account::API accountapi;
|
||||
RegisteredChannel chanmode;
|
||||
RegisteredUser usermode;
|
||||
|
||||
public:
|
||||
ModuleServices()
|
||||
: Module(VF_VENDOR, "Provides support for integrating with a services server.")
|
||||
, accountapi(this)
|
||||
, chanmode(this)
|
||||
, usermode(this)
|
||||
{
|
||||
}
|
||||
|
||||
void OnUserPostNick(User* user, const std::string& oldnick) override
|
||||
{
|
||||
if (user->IsModeSet(usermode) && irc::equals(oldnick, user->nick))
|
||||
usermode.RemoveMode(user);
|
||||
}
|
||||
};
|
||||
|
||||
MODULE_INIT(ModuleServices)
|
@ -45,53 +45,6 @@ enum
|
||||
RPL_LOGGEDOUT = 901
|
||||
};
|
||||
|
||||
/** Channel mode +r - mark a channel as identified
|
||||
*/
|
||||
class RegisteredChannel final
|
||||
: public SimpleChannelMode
|
||||
{
|
||||
public:
|
||||
RegisteredChannel(Module* Creator)
|
||||
: SimpleChannelMode(Creator, "c_registered", 'r')
|
||||
{
|
||||
}
|
||||
|
||||
ModeAction OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override
|
||||
{
|
||||
if (IS_LOCAL(source))
|
||||
{
|
||||
source->WriteNumeric(ERR_NOPRIVILEGES, "Only a server may modify the +r channel mode");
|
||||
return MODEACTION_DENY;
|
||||
}
|
||||
|
||||
return SimpleChannelMode::OnModeChange(source, dest, channel, change);
|
||||
}
|
||||
};
|
||||
|
||||
/** User mode +r - mark a user as identified
|
||||
*/
|
||||
class RegisteredUser final
|
||||
: public SimpleUserMode
|
||||
{
|
||||
|
||||
public:
|
||||
RegisteredUser(Module* Creator)
|
||||
: SimpleUserMode(Creator, "u_registered", 'r')
|
||||
{
|
||||
}
|
||||
|
||||
ModeAction OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override
|
||||
{
|
||||
if (IS_LOCAL(source))
|
||||
{
|
||||
source->WriteNumeric(ERR_NOPRIVILEGES, "Only a server may modify the +r channel mode");
|
||||
return MODEACTION_DENY;
|
||||
}
|
||||
|
||||
return SimpleUserMode::OnModeChange(source, dest, channel, change);
|
||||
}
|
||||
};
|
||||
|
||||
class AccountExtItemImpl final
|
||||
: public StringExtItem
|
||||
{
|
||||
@ -268,8 +221,6 @@ private:
|
||||
SimpleChannelMode reginvitemode;
|
||||
SimpleChannelMode regmoderatedmode;
|
||||
SimpleUserMode regdeafmode;
|
||||
RegisteredChannel chanregmode;
|
||||
RegisteredUser userregmode;
|
||||
AccountAPIImpl accountapi;
|
||||
AccountExtBan accountextban;
|
||||
UnauthedExtBan unauthedextban;
|
||||
@ -285,8 +236,6 @@ public:
|
||||
, reginvitemode(this, "reginvite", 'R')
|
||||
, regmoderatedmode(this, "regmoderated", 'M')
|
||||
, regdeafmode(this, "regdeaf", 'R')
|
||||
, chanregmode(this)
|
||||
, userregmode(this)
|
||||
, accountapi(this)
|
||||
, accountextban(this, accountapi)
|
||||
, unauthedextban(this, accountapi)
|
||||
@ -316,13 +265,6 @@ public:
|
||||
whois.SendLine(RPL_WHOISREGNICK, "is a registered nick");
|
||||
}
|
||||
|
||||
void OnUserPostNick(User* user, const std::string& oldnick) override
|
||||
{
|
||||
/* On nickchange, if they have +r, remove it */
|
||||
if ((user->IsModeSet(userregmode)) && (ServerInstance->Users.FindNick(oldnick) != user))
|
||||
userregmode.RemoveMode(user);
|
||||
}
|
||||
|
||||
ModResult HandleMessage(User* user, const MessageTarget& target)
|
||||
{
|
||||
if (!IS_LOCAL(user))
|
||||
|
Loading…
x
Reference in New Issue
Block a user