summaryrefslogtreecommitdiff
path: root/modules/rpc/rpc_main.cpp
diff options
context:
space:
mode:
authorSadie Powell <sadie@witchery.services>2025-02-24 05:46:43 +0000
committerSadie Powell <sadie@witchery.services>2025-02-25 19:59:23 +0000
commite500258ce4b01bc02539db99c12fa7d9428cb0a6 (patch)
tree5a9fd3900ad3104741b61a907c3f8f2a99323f35 /modules/rpc/rpc_main.cpp
parent801a748e256cb7c4952969103f2f2eaf5ee36552 (diff)
Add the rpc_data module.
- Add rewritten and namespaced versions of the channel, oper, user events. - Add the following new events: * anope.listChannels * anope.listOpers * anope.listServers * anope.listUsers * anope.server
Diffstat (limited to 'modules/rpc/rpc_main.cpp')
-rw-r--r--modules/rpc/rpc_main.cpp139
1 files changed, 0 insertions, 139 deletions
diff --git a/modules/rpc/rpc_main.cpp b/modules/rpc/rpc_main.cpp
index 2f22e82c7..0f35de142 100644
--- a/modules/rpc/rpc_main.cpp
+++ b/modules/rpc/rpc_main.cpp
@@ -167,136 +167,6 @@ public:
}
};
-class ChannelRPCEvent final
- : public RPC::Event
-{
-public:
- ChannelRPCEvent()
- : RPC::Event("channel")
- {
- }
-
- bool Run(RPC::ServiceInterface *iface, HTTPClient *client, RPC::Request &request) override
- {
- if (request.data.empty())
- {
- request.Error(RPC::ERR_INVALID_PARAMS, "Invalid parameters");
- return true;
- }
-
- Channel *c = Channel::Find(request.data[0]);
-
- auto &root = request.Root();
- root.Reply("name", c ? c->name : request.data[0]);
-
- if (c)
- {
- root.Reply("bancount", c->HasMode("BAN"));
- auto &bans = root.ReplyArray("bans");
- for (auto &ban : c->GetModeList("BAN"))
- bans.Reply(ban);
-
- root.Reply("exceptcount", c->HasMode("EXCEPT"));
- auto &excepts = root.ReplyArray("excepts");
- for (auto &except : c->GetModeList("EXCEPT"))
- excepts.Reply(except);
-
- root.Reply("invitecount", c->HasMode("INVITEOVERRIDE"));
- auto &invites = root.ReplyArray("invites");
- for (auto &invite : c->GetModeList("INVITEOVERRIDE"))
- invites.Reply(invite);
-
- auto &users = root.ReplyArray("users");
- for (const auto &[_, uc] : c->users)
- users.Reply(uc->status.BuildModePrefixList() + uc->user->nick);
-
- if (!c->topic.empty())
- root.Reply("topic", c->topic);
-
- if (!c->topic_setter.empty())
- root.Reply("topicsetter", c->topic_setter);
-
- root.Reply("topictime", c->topic_time);
- root.Reply("topicts", c->topic_ts);
- }
- return true;
- }
-};
-
-class UserRPCEvent final
- : public RPC::Event
-{
-public:
- UserRPCEvent()
- : RPC::Event("user")
- {
- }
-
- bool Run(RPC::ServiceInterface *iface, HTTPClient *client, RPC::Request &request) override
- {
- if (request.data.empty())
- {
- request.Error(RPC::ERR_INVALID_PARAMS, "Invalid parameters");
- return true;
- }
-
- User *u = User::Find(request.data[0]);
-
- auto &root = request.Root();
- root.Reply("nick", u ? u->nick : request.data[0]);
-
- if (u)
- {
- root.Reply("ident", u->GetIdent());
- root.Reply("vident", u->GetVIdent());
- root.Reply("host", u->host);
- if (!u->vhost.empty())
- root.Reply("vhost", u->vhost);
- if (!u->chost.empty())
- root.Reply("chost", u->chost);
- root.Reply("ip", u->ip.addr());
- root.Reply("timestamp", u->timestamp);
- root.Reply("signon", u->signon);
- if (u->IsIdentified())
- {
- root.Reply("account", u->Account()->display);
- if (u->Account()->o)
- root.Reply("opertype", u->Account()->o->ot->GetName());
- }
-
- auto &channels = root.ReplyArray("channels");
- for (const auto &[_, cc] : u->chans)
- channels.Reply(cc->status.BuildModePrefixList() + cc->chan->name);
- }
- return true;
- }
-};
-
-class OpersRPCEvent final
- : public RPC::Event
-{
-public:
- OpersRPCEvent()
- : RPC::Event("opers")
- {
- }
-
- bool Run(RPC::ServiceInterface *iface, HTTPClient *client, RPC::Request &request) override
- {
- auto &root = request.Root();
- for (auto *ot : Config->MyOperTypes)
- {
- Anope::string perms;
- for (const auto &priv : ot->GetPrivs())
- perms += " " + priv;
- for (const auto &command : ot->GetCommands())
- perms += " " + command;
- root.Reply(ot->GetName(), perms);
- }
- return true;
- }
-};
-
class NoticeRPCEvent final
: public RPC::Event
{
@@ -334,9 +204,6 @@ private:
CommandRPCEvent commandrpcevent;
CheckAuthenticationRPCEvent checkauthenticationrpcevent;
StatsRPCEvent statsrpcevent;
- ChannelRPCEvent channelrpcevent;
- UserRPCEvent userrpcevent;
- OpersRPCEvent opersrpcevent;
NoticeRPCEvent noticerpcevent;
public:
@@ -352,9 +219,6 @@ public:
rpc->Register(&commandrpcevent);
rpc->Register(&checkauthenticationrpcevent);
rpc->Register(&statsrpcevent);
- rpc->Register(&channelrpcevent);
- rpc->Register(&userrpcevent);
- rpc->Register(&opersrpcevent);
rpc->Register(&noticerpcevent);
}
@@ -366,9 +230,6 @@ public:
rpc->Unregister(&commandrpcevent);
rpc->Unregister(&checkauthenticationrpcevent);
rpc->Unregister(&statsrpcevent);
- rpc->Unregister(&channelrpcevent);
- rpc->Unregister(&userrpcevent);
- rpc->Unregister(&opersrpcevent);
rpc->Unregister(&noticerpcevent);
}
};