2022-08-24 09:06:00 -05:00
|
|
|
package handler
|
2022-08-07 07:13:17 -05:00
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"runtime"
|
|
|
|
|
2022-08-23 11:52:36 -05:00
|
|
|
"git.kill0.net/chill9/beepboop/bot"
|
2022-08-24 09:06:00 -05:00
|
|
|
"git.kill0.net/chill9/beepboop/lib"
|
2022-08-07 07:13:17 -05:00
|
|
|
"github.com/bwmarrin/discordgo"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
SourceURI = "https://git.kill0.net/chill9/bb"
|
|
|
|
)
|
|
|
|
|
|
|
|
type (
|
|
|
|
VersionHandler struct {
|
2022-08-23 11:52:36 -05:00
|
|
|
config bot.Config
|
2022-08-07 07:13:17 -05:00
|
|
|
Name string
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
func NewVersionHandler(s string) *VersionHandler {
|
2022-09-04 22:36:14 -05:00
|
|
|
return &VersionHandler{Name: s}
|
2022-08-07 07:13:17 -05:00
|
|
|
}
|
|
|
|
|
2022-08-23 11:52:36 -05:00
|
|
|
func (h *VersionHandler) SetConfig(config bot.Config) {
|
2022-08-07 07:13:17 -05:00
|
|
|
h.config = config
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *VersionHandler) Handle(s *discordgo.Session, m *discordgo.MessageCreate) {
|
|
|
|
if m.Author.ID == s.State.User.ID {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-09-05 12:54:56 -05:00
|
|
|
if !lib.ContainsCommand(m.Content, h.config.Prefix, h.Name) {
|
2022-08-07 07:13:17 -05:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
s.ChannelMessageSend(m.ChannelID, fmt.Sprintf(
|
|
|
|
"go version: %s\nplatform: %s\nos: %s\nsource: %s\n",
|
|
|
|
runtime.Version(),
|
|
|
|
runtime.GOARCH,
|
|
|
|
runtime.GOOS,
|
|
|
|
SourceURI,
|
|
|
|
))
|
|
|
|
}
|