gostoat is an API wrapper that allows you to create stoat.chat bots as well as use stoat webhooks
If you need help with using the gostoat package, join the gostoat stoat.chat server.
NOTICE: This library is still a heavy work in progress. Expect unfinished and buggy features.
This Go package is not officially endorsed by or affiliated with stoat.chat
This assumes you already have a Go environment on your system. If not, download Go from here. Make sure you have Go 1.21 or newer.
Install gostoat by using the following command.
go get github.com/MatthewsDevelopment/gostoatAfter installing the package, import the gofluxer package using this within your code.
import (
"log"
"strings"
"fmt"
"github.com/MatthewsDevelopment/gostoat"
)Here is a basic example of a ping pong bot.
package main
import (
"log"
"strings"
"fmt"
"github.com/MatthewsDevelopment/gostoat"
)
func main() {
token := "STOATBOTTOKEN" // Replace STOATBOTTOKEN with your actual stoat.chat bot token.
if token == "" {
log.Fatal("STOATBOTTOKEN environment variable not set.")
}
client := stoat.NewClient(token)
client.OnMessage(handlePingResponse)
log.Fatal(client.ConnectAndRun())
}
func handlePingResponse(c *stoat.Client, m stoat.Message) {
if strings.ToLower(strings.TrimSpace(m.Content)) == "ping" {
content := "pong!"
err := c.SendMessage(m.ChannelID, stoat.SendMessagePayload{
Content: &content,
})
if err != nil {
log.Printf("An error has occured: Failed to send 'pong' message: %v", err)
}
}
}You can refer to the examples directory for more examples to see how to use this Go package
- Installing gostoat will now include github.com/gorilla/websocket v1.5.3 within the go.mod file which is required to use this package.
- Improved the logging text.
- The first early release version of gostoat. This is a testing version so I can get suggestions on what to add or fix.
- Supports message and command handlers.
- Supports NSFW channel and bot owner checks.
- Supports using webhooks
- Uses MIT license.
- Added a example_pingpong.go example, a example_commands.go example, and a example_webhooks.go example.