diff options
| author | 2024-03-08 11:42:39 +0000 | |
|---|---|---|
| committer | 2024-03-08 11:45:45 +0000 | |
| commit | 38d24933a450dcee18dd9d099005998555c732ab (patch) | |
| tree | 3ed345f4656d88370b48896097667512a6d71cf8 /src/modules | |
| parent | Clear bans on the first server that a SVSCMODE reaches. (diff) | |
Merge the svsoper from contrib into the services module.
Diffstat (limited to 'src/modules')
| -rw-r--r-- | src/modules/m_services.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/modules/m_services.cpp b/src/modules/m_services.cpp index 98894fdce..6c9330a7b 100644 --- a/src/modules/m_services.cpp +++ b/src/modules/m_services.cpp @@ -385,6 +385,48 @@ public: } }; +class CommandSVSOper final + : public Command +{ +public: + CommandSVSOper(Module* Creator) + : Command(Creator, "SVSOPER", 2, 2) + { + access_needed = CmdAccess::SERVER; + } + + CmdResult Handle(User* user, const Params& parameters) override + { + if (!user->server->IsService()) + return CmdResult::FAILURE; + + auto* target = ServerInstance->Users.FindUUID(parameters[0]); + if (!target) + return CmdResult::FAILURE; + + if (IS_LOCAL(target)) + { + auto iter = ServerInstance->Config->OperTypes.find(parameters[1]); + if (iter == ServerInstance->Config->OperTypes.end()) + return CmdResult::FAILURE; + + auto automatic = parameters.GetTags().find("~automatic") != parameters.GetTags().end(); + auto account = std::make_shared<OperAccount>(MODNAME, iter->second, ServerInstance->Config->EmptyTag); + target->OperLogin(account, automatic, true); + } + + return CmdResult::SUCCESS; + } + + RouteDescriptor GetRouting(User* user, const Params& parameters) override + { + auto* target = ServerInstance->Users.FindUUID(parameters[0]); + if (!target) + return ROUTE_LOCALONLY; + return ROUTE_OPT_UCAST(target->server); + } +}; + class CommandSVSPart final : public Command { @@ -487,6 +529,7 @@ private: CommandSVSHold svsholdcmd; CommandSVSJoin svsjoincmd; CommandSVSNick svsnickcmd; + CommandSVSOper svsopercmd; CommandSVSPart svspartcmd; CommandSVSTopic svstopiccmd; bool accountoverrideshold; @@ -544,6 +587,7 @@ public: , svsholdcmd(this) , svsjoincmd(this) , svsnickcmd(this) + , svsopercmd(this) , svspartcmd(this) , svstopiccmd(this) { |
