mutiny

module
v0.0.0-...-fa60fbe Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2021 License: ISC

README

mutiny

A library for the Revolt bot API, heavily inspired by arikawa and discordgo.

Note that this library will not support user accounts, only bot accounts (which ironically is pretty much the opposite of the libraries we're inspired by)

Acknowledgements

Some of the code here (especially the gateway code) is based on or copied from arikawa or discordgo.

Example

A basic ping-pong example:

import (
	"fmt"
	"log"
	"os"
	"time"

	"github.com/starshine-sys/mutiny/gateway"
	"github.com/starshine-sys/mutiny/session"
)

func main() {
	s, err := session.New(os.Getenv("TOKEN"))
	if err != nil {
		log.Fatalf("Error creating session: %v", err)
	}

	s.Handler.AddHandler(func(m *gateway.MessageEvent) {
		log.Printf("Received a message! Content: %v", m.String())

		if m.String() == "/ping" {
			_, err := s.SendMessage(m.ChannelID, fmt.Sprintf("Pong! %v", s.Ping().Round(time.Millisecond)))
			if err != nil {
				log.Printf("Error sending message: %v", err)
			}
		}
	})

	err = s.Open()
	if err != nil {
		log.Fatalf("Error opening session: %v", err)
	}

	select {}
}

License

License information can be found in the LICENSE file in this repository.

Any code from other projects (mentioned in the specific files) is licensed under those projects' licenses.

Directories

Path Synopsis
Package api contains types and methods for interacting with Revolt's REST API.
Package api contains types and methods for interacting with Revolt's REST API.
Package gateway contains a gateway client and event handlers.
Package gateway contains a gateway client and event handlers.
Package revolt contains types shared by the other packages.
Package revolt contains types shared by the other packages.
util
httputil
Package httputil implements a wrapper around the standard library's HTTP client.
Package httputil implements a wrapper around the standard library's HTTP client.
jsonutil
Package jsonutil implements types and functions to make it easier to handle JSON.
Package jsonutil implements types and functions to make it easier to handle JSON.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL