Skip to content
This repository has been archived by the owner on Nov 25, 2022. It is now read-only.

REST API for ghost2-wrapper #55

Open
weakphish opened this issue Sep 23, 2020 · 2 comments
Open

REST API for ghost2-wrapper #55

weakphish opened this issue Sep 23, 2020 · 2 comments
Labels
feature New feature or request planned/2.x

Comments

@weakphish
Copy link

@cbryant02 mentioned exposing a REST API for the GUI wrapper to work through. I'd be happy to take a crack at this if given a little direction/place to start/some basic requirements, since I'm not terribly familiar with the code base beyond what I've contributed in command modules.

@zzzowoey zzzowoey added feature New feature or request planned/2.x labels Sep 23, 2020
@zzzowoey zzzowoey changed the title [Feature] Expose API to GUI wrapper REST API Sep 23, 2020
@zzzowoey zzzowoey changed the title REST API REST API for ghost2-wrapper Sep 23, 2020
@zzzowoey
Copy link
Member

zzzowoey commented Sep 23, 2020

As much as I would like to, I haven't had much time on my hands to focus on this project. Here are some basic ideas, though. I'll continue to expand on this as we go.

API outline

  • GET requests
    • Bot ID
    • Operator ID
    • Uptime
    • Guild count

Handling events

Communicating events from the bot to the wrapper should be done over a WebSocket. Here's some example payloads.

User 195635151005417472 in guild 175928847299117063 ran g!wikipedia dog

{
	"timestamp": "2020-09-23T18:16:09+00:00",
	"event_type": "command",
	"event_data": {
		"name": "wikipedia",
		"args": { "dog" },
		"user_id": "195635151005417472",
		"guild_id": "175928847299117063"
   }
}

ghost2 made a request to the Wikipedia API for "dog"

{
	"timestamp": "2020-09-23T18:16:10+00:00",
	"event_type": "get",
	"event_data": {
		"url": "https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch=dog&utf8=&format=json"
	}
}

Here's a handful of events to start with, including some data to attach to the payload.

Type Data Description
command name, args, user_id, guild_id A user invoked a command.
new_operator user_id A user became the bot operator.
music_create guild_id A MusicService was created.
music_queue guild_id, track A MusicService queued a track.
music_destroy guild_id A MusicService was destroyed.
get url A web request to an external API was made.

@weakphish
Copy link
Author

I plan on working on this in November, when my semester ends as I pretty much have zero time outside of school. This is assuming nobody else takes up the task, to which they are of course welcome to 🙂

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature New feature or request planned/2.x
Projects
None yet
Development

No branches or pull requests

2 participants