diff --git a/README.md b/README.md index c07d30f..498ae66 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,123 @@ # Revoltgo -Revoltgo is a go package for writing bots easily. \ No newline at end of file + +Revoltgo is a go package for writing bots / self-bots in revolt easily. + +**NOTE**: This package is still under development and not finished. Create an issue if you found a bug. + +## Features + +- Can listen a event multiple times +- Easy to use +- Supports self-bots +- Simple cache system + +## Installation + +- Create a new project and init go.mod file. `go mod init example` +- Install the package using `go get github.com/5elenay/revoltgo` + +## API Reference + +Click [here](https://pkg.go.dev/github.com/5elenay/revoltgo) for api reference. + +## Ping Pong Example (Bot) + +```go +package main + +import ( + "os" + "os/signal" + "syscall" + + "github.com/5elenay/revoltgo" +) + +func main() { + // Init a new client. + client := revoltgo.Client{ + Token: "bot token", + } + + // Listen a on message event. + client.OnMessage(func(m *revoltgo.Message) { + if m.Content == "!ping" { + sendMsg := &revoltgo.SendMessage{} + sendMsg.SetContent("🏓 Pong!") + + m.Reply(true, sendMsg) + } + }) + + // Start the client. + client.Start() + + // Wait for close. + sc := make(chan os.Signal, 1) + + signal.Notify( + sc, + syscall.SIGINT, + syscall.SIGTERM, + os.Interrupt, + ) + <-sc + + // Destroy client. + client.Destroy() +} + +``` + +## Ping Pong Example (Self-Bot) + +```go +package main + +import ( + "os" + "os/signal" + "syscall" + + "github.com/5elenay/revoltgo" +) + +func main() { + // Init a new client. + client := revoltgo.Client{ + SelfBot: &revoltgo.SelfBot{ + Id: "session id", + SessionToken: "session token", + UserId: "user id", + }, + } + + // Listen a on message event. + client.OnMessage(func(m *revoltgo.Message) { + if m.Content == "!ping" { + sendMsg := &revoltgo.SendMessage{} + sendMsg.SetContent("🏓 Pong!") + + m.Reply(true, sendMsg) + } + }) + + // Start the client. + client.Start() + + // Wait for close. + sc := make(chan os.Signal, 1) + + signal.Notify( + sc, + syscall.SIGINT, + syscall.SIGTERM, + os.Interrupt, + ) + <-sc + + // Destroy client. + client.Destroy() +} + +``` diff --git a/go.mod b/go.mod index 06dbd06..3f86705 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.17 require ( github.com/gorilla/websocket v1.4.2 // indirect - github.com/oklog/ulid/v2 v2.0.2 // indirect + github.com/oklog/ulid/v2 v2.0.2 github.com/sacOO7/go-logger v0.0.0-20180719173527-9ac9add5a50d // indirect - github.com/sacOO7/gowebsocket v0.0.0-20210515122958-9396f1a71e23 // indirect + github.com/sacOO7/gowebsocket v0.0.0-20210515122958-9396f1a71e23 )