Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ben-forster/revolt
Go wrapper for https://revolt.chat/
https://github.com/ben-forster/revolt
go revolt revolt-api revolt-api-wrapper revolt-chat revolt-chat-api-wrapper
Last synced: about 1 month ago
JSON representation
Go wrapper for https://revolt.chat/
- Host: GitHub
- URL: https://github.com/ben-forster/revolt
- Owner: ben-forster
- License: mit
- Created: 2023-04-25T19:02:38.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-24T15:23:31.000Z (12 months ago)
- Last Synced: 2024-08-03T21:02:00.663Z (5 months ago)
- Topics: go, revolt, revolt-api, revolt-api-wrapper, revolt-chat, revolt-chat-api-wrapper
- Language: Go
- Homepage:
- Size: 119 KB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 15
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-revolt - revolt.go - Go wrapper for Revolt. (💻 API Libraries / Go)
README
[![Go Reference](https://pkg.go.dev/badge/github.com/ben-forster/revolt.svg)](https://pkg.go.dev/github.com/ben-forster/revolt)
[![Go Report](https://goreportcard.com/badge/github.com/ben-forster/revolt)](https://goreportcard.com/report/github.com/ben-forster/revolt)
[![Go Version](https://img.shields.io/github/go-mod/go-version/ben-forster/revolt?filename=go.mod)](https://golang.org/doc/devel/release.html)
[![License](https://img.shields.io/badge/License-MIT%202.0-blue.svg)](https://github.com/ben-forster/revolt/blob/master/LICENSE)
[![Revolt.go Version](https://img.shields.io/github/v/release/ben-forster/revolt?label=release)](https://github.com/ben-forster/revolt/releases/latest)# Revolt.go
Revolt.go is a Go package for writing bots and self-bots for Revolt.
## Features
- Event listener.
- Easy to use.
- Support for self bots.
- Simple caching system.## Getting Started
### Installation
- Create a new project and initiate the go.mod file. `go mod init example`
- Install the package using `go get github.com/ben-forster/revolt`
- Create your main bot file. `touch main.go`## API Reference
Click [here](https://pkg.go.dev/github.com/ben-forster/[email protected]) for the library's API reference.Official documentation will come in the near future.
## Notice
Please note that you will need **Go 1.21** to use this library.
This package is still under development and while you can create a working bot, the library is not finished. You can see a development roadmap [here](https://github.com/users/ben-forster/projects/8). Please create an issue if you would like to contribute.
## Ping Pong Example (Bot)
```go
package mainimport (
"os"
"os/signal"
"syscall""github.com/ben-forster/revolt"
)func main() {
// Init a new client.
client := revolt.Client{
Token: "bot token",
}// Listen a on message event.
client.OnMessage(func(m *revolt.Message) {
if m.Content == "!ping" {
sendMsg := &revolt.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 mainimport (
"os"
"os/signal"
"syscall""github.com/ben-forster/revolt"
)func main() {
// Init a new client.
client := revolt.Client{
SelfBot: &revolt.SelfBot{
Id: "session id",
SessionToken: "session token",
UserId: "user id",
},
}// Listen a on message event.
client.OnMessage(func(m *revolt.Message) {
if m.Content == "!ping" {
sendMsg := &revolt.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()
}```
## Credit
This project is a mantained and re-worked version of 5elenay's library [revoltgo](https://github.com/5elenay/revoltgo).