Compare commits
No commits in common. "4c5849daae8b0c689438f2eff48c2557cf5282e3" and "a1d612abc03cadb902c32cd4b0f1bf9decbe6670" have entirely different histories.
4c5849daae
...
a1d612abc0
@ -1,87 +0,0 @@
|
||||
package bot
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.kill0.net/chill9/beepboop/lib"
|
||||
"github.com/bwmarrin/discordgo"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
var (
|
||||
DefaultCommander *Commander
|
||||
)
|
||||
|
||||
type (
|
||||
Commander struct {
|
||||
commands map[string]*Command
|
||||
}
|
||||
|
||||
Command struct {
|
||||
Name string
|
||||
Config Config
|
||||
Func func(cmd *Command, args []string) error
|
||||
Session *discordgo.Session
|
||||
Message *discordgo.MessageCreate
|
||||
}
|
||||
)
|
||||
|
||||
func init() {
|
||||
DefaultCommander = NewCommander()
|
||||
}
|
||||
|
||||
func NewCommander() *Commander {
|
||||
cmdr := new(Commander)
|
||||
cmdr.commands = make(map[string]*Command)
|
||||
return cmdr
|
||||
}
|
||||
|
||||
func (cmdr *Commander) AddCommand(cmd *Command) {
|
||||
cmdr.commands[cmd.Name] = cmd
|
||||
}
|
||||
|
||||
func (cmdr *Commander) GetCommand(name string) (*Command, bool) {
|
||||
cmd, ok := cmdr.commands[name]
|
||||
return cmd, ok
|
||||
}
|
||||
|
||||
func AddCommand(cmd *Command) {
|
||||
DefaultCommander.AddCommand(cmd)
|
||||
}
|
||||
|
||||
func GetCommand(name string) (*Command, bool) {
|
||||
cmd, ok := DefaultCommander.GetCommand(name)
|
||||
return cmd, ok
|
||||
}
|
||||
|
||||
func NewCommandHandler(config Config) func(s *discordgo.Session, m *discordgo.MessageCreate) {
|
||||
return func(s *discordgo.Session, m *discordgo.MessageCreate) {
|
||||
var cmd *Command
|
||||
|
||||
if m.Author.ID == s.State.User.ID {
|
||||
return
|
||||
}
|
||||
|
||||
if !lib.HasCommand(m.Content, config.Prefix) {
|
||||
return
|
||||
}
|
||||
|
||||
cmdName, args := lib.SplitCommandAndArgs(m.Content, config.Prefix)
|
||||
|
||||
cmd, ok := GetCommand(cmdName)
|
||||
if ok {
|
||||
cmd.Config = config
|
||||
cmd.Name = cmdName
|
||||
cmd.Session = s
|
||||
cmd.Message = m
|
||||
|
||||
log.Debugf("command: %+v, args: %+v", cmd.Name, args)
|
||||
cmd.Func(cmd, args)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
log.Warnf("unknown command: %+v, args: %+v", cmdName, args)
|
||||
s.ChannelMessageSend(m.ChannelID, fmt.Sprintf("unknown command: %s", cmdName))
|
||||
}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
package commands
|
||||
|
||||
import (
|
||||
"git.kill0.net/chill9/beepboop/bot"
|
||||
"git.kill0.net/chill9/beepboop/lib"
|
||||
)
|
||||
|
||||
type Coin bool
|
||||
|
||||
func (c *Coin) Flip() bool {
|
||||
*c = Coin(lib.Itob(lib.RandInt(0, 1)))
|
||||
return bool(*c)
|
||||
}
|
||||
|
||||
func CoinCommand(cmd *bot.Command, args []string) error {
|
||||
var (
|
||||
c Coin
|
||||
msg string
|
||||
)
|
||||
|
||||
if c.Flip() {
|
||||
msg = "heads"
|
||||
} else {
|
||||
msg = "tails"
|
||||
}
|
||||
|
||||
cmd.Session.ChannelMessageSend(cmd.Message.ChannelID, msg)
|
||||
return nil
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
package commands
|
||||
|
||||
import (
|
||||
"git.kill0.net/chill9/beepboop/bot"
|
||||
)
|
||||
|
||||
func PingCommand(cmd *bot.Command, args []string) error {
|
||||
cmd.Session.ChannelMessageSend(cmd.Message.ChannelID, "pong")
|
||||
return nil
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
package commands
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"git.kill0.net/chill9/beepboop/bot"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func TimeCommand(cmd *bot.Command, args []string) error {
|
||||
var (
|
||||
t time.Time
|
||||
tz string
|
||||
)
|
||||
|
||||
now := time.Now()
|
||||
|
||||
if len(args) == 1 {
|
||||
tz = args[0]
|
||||
loc, err := time.LoadLocation(tz)
|
||||
if err != nil {
|
||||
log.Warnf("failed to load location: %s", err)
|
||||
cmd.Session.ChannelMessageSend(cmd.Message.ChannelID, err.Error())
|
||||
return nil
|
||||
}
|
||||
t = now.In(loc)
|
||||
} else {
|
||||
t = now
|
||||
}
|
||||
|
||||
cmd.Session.ChannelMessageSend(cmd.Message.ChannelID, fmt.Sprint(t))
|
||||
return nil
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
package commands
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"runtime"
|
||||
|
||||
"git.kill0.net/chill9/beepboop/bot"
|
||||
)
|
||||
|
||||
const (
|
||||
SourceURI = "https://git.kill0.net/chill9/bb"
|
||||
)
|
||||
|
||||
func VersionCommand(cmd *bot.Command, args []string) error {
|
||||
cmd.Session.ChannelMessageSend(cmd.Message.ChannelID, fmt.Sprintf(
|
||||
"go version: %s\nplatform: %s\nos: %s\nsource: %s\n",
|
||||
runtime.Version(),
|
||||
runtime.GOARCH,
|
||||
runtime.GOOS,
|
||||
SourceURI,
|
||||
))
|
||||
return nil
|
||||
}
|
52
bot/handler/coin.go
Normal file
52
bot/handler/coin.go
Normal file
@ -0,0 +1,52 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"git.kill0.net/chill9/beepboop/bot"
|
||||
"git.kill0.net/chill9/beepboop/lib"
|
||||
"github.com/bwmarrin/discordgo"
|
||||
)
|
||||
|
||||
type (
|
||||
Coin bool
|
||||
|
||||
CoinHandler struct {
|
||||
config bot.Config
|
||||
Name string
|
||||
}
|
||||
)
|
||||
|
||||
func (c *Coin) Flip() bool {
|
||||
*c = Coin(lib.Itob(lib.RandInt(0, 1)))
|
||||
return bool(*c)
|
||||
}
|
||||
|
||||
func NewCoinHandler(s string) *CoinHandler {
|
||||
return &CoinHandler{Name: s}
|
||||
}
|
||||
|
||||
func (h *CoinHandler) SetConfig(config bot.Config) {
|
||||
h.config = config
|
||||
}
|
||||
|
||||
func (h *CoinHandler) Handle(s *discordgo.Session, m *discordgo.MessageCreate) {
|
||||
var (
|
||||
c Coin
|
||||
msg string
|
||||
)
|
||||
|
||||
if m.Author.ID == s.State.User.ID {
|
||||
return
|
||||
}
|
||||
|
||||
if !lib.ContainsCommand(m.Content, h.config.Prefix, h.Name) {
|
||||
return
|
||||
}
|
||||
|
||||
if c.Flip() {
|
||||
msg = "heads"
|
||||
} else {
|
||||
msg = "tails"
|
||||
}
|
||||
|
||||
s.ChannelMessageSend(m.ChannelID, msg)
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package commands
|
||||
package handler
|
||||
|
||||
import (
|
||||
"errors"
|
||||
@ -8,6 +8,8 @@ import (
|
||||
"strings"
|
||||
|
||||
"git.kill0.net/chill9/beepboop/bot"
|
||||
"git.kill0.net/chill9/beepboop/lib"
|
||||
"github.com/bwmarrin/discordgo"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
@ -50,16 +52,36 @@ func (d *Deck) Deal(n int) ([]Card, error) {
|
||||
return hand, err
|
||||
}
|
||||
|
||||
func DealCommand(cmd *bot.Command, args []string) error {
|
||||
func NewDealHandler(s string) *DealHandler {
|
||||
h := new(DealHandler)
|
||||
h.Name = s
|
||||
return h
|
||||
}
|
||||
|
||||
func (h *DealHandler) SetConfig(config bot.Config) {
|
||||
h.config = config
|
||||
}
|
||||
|
||||
func (h *DealHandler) Handle(s *discordgo.Session, m *discordgo.MessageCreate) {
|
||||
if m.Author.ID == s.State.User.ID {
|
||||
return
|
||||
}
|
||||
|
||||
if !lib.ContainsCommand(m.Content, h.config.Prefix, h.Name) {
|
||||
return
|
||||
}
|
||||
|
||||
rand.Shuffle(len(deck), func(i, j int) {
|
||||
deck[i], deck[j] = deck[j], deck[i]
|
||||
})
|
||||
|
||||
log.Debugf("%+v", deck)
|
||||
|
||||
_, args := lib.SplitCommandAndArgs(m.Content, h.config.Prefix)
|
||||
|
||||
if len(args) != 1 {
|
||||
cmd.Session.ChannelMessageSend(cmd.Message.ChannelID, fmt.Sprintf("help: `!%s <n>`", cmd.Name))
|
||||
return nil
|
||||
s.ChannelMessageSend(m.ChannelID, fmt.Sprintf("help: `!%s <n>`", h.Name))
|
||||
return
|
||||
}
|
||||
|
||||
n, err := strconv.Atoi(args[0])
|
||||
@ -69,12 +91,11 @@ func DealCommand(cmd *bot.Command, args []string) error {
|
||||
|
||||
hand, err := deck.Deal(n)
|
||||
if err != nil {
|
||||
cmd.Session.ChannelMessageSend(cmd.Message.ChannelID, fmt.Sprintf("error: %s\n", err))
|
||||
return nil
|
||||
s.ChannelMessageSend(m.ChannelID, fmt.Sprintf("error: %s\n", err))
|
||||
return
|
||||
}
|
||||
|
||||
cmd.Session.ChannelMessageSend(cmd.Message.ChannelID, JoinCards(hand, " "))
|
||||
return nil
|
||||
s.ChannelMessageSend(m.ChannelID, JoinCards(hand, " "))
|
||||
}
|
||||
|
||||
func JoinCards(h []Card, sep string) string {
|
@ -1,4 +1,4 @@
|
||||
package commands
|
||||
package handler
|
||||
|
||||
import (
|
||||
"errors"
|
||||
@ -9,6 +9,7 @@ import (
|
||||
|
||||
"git.kill0.net/chill9/beepboop/bot"
|
||||
"git.kill0.net/chill9/beepboop/lib"
|
||||
"github.com/bwmarrin/discordgo"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
@ -24,6 +25,11 @@ type (
|
||||
Rolls []int
|
||||
S string
|
||||
}
|
||||
|
||||
RollHandler struct {
|
||||
config bot.Config
|
||||
Name string
|
||||
}
|
||||
)
|
||||
|
||||
func NewRoll(n, d int) *Roll {
|
||||
@ -78,19 +84,42 @@ func (r *Roll) RollDice() {
|
||||
}
|
||||
}
|
||||
|
||||
func RollCommand(cmd *bot.Command, args []string) error {
|
||||
func NewRollHandler(s string) *RollHandler {
|
||||
return &RollHandler{Name: s}
|
||||
}
|
||||
|
||||
func (h *RollHandler) SetConfig(config bot.Config) {
|
||||
h.config = config
|
||||
}
|
||||
|
||||
func (h *RollHandler) Handle(s *discordgo.Session, m *discordgo.MessageCreate) {
|
||||
var (
|
||||
err error
|
||||
msg, roll string
|
||||
r *Roll
|
||||
)
|
||||
|
||||
roll = args[0]
|
||||
if m.Author.ID == s.State.User.ID {
|
||||
return
|
||||
}
|
||||
|
||||
if !lib.ContainsCommand(m.Content, h.config.Prefix, h.Name) {
|
||||
return
|
||||
}
|
||||
|
||||
x := strings.Split(m.Content, " ")
|
||||
|
||||
if len(x) != 2 {
|
||||
s.ChannelMessageSend(m.ChannelID, "help: `!roll <n>d<s>`")
|
||||
return
|
||||
}
|
||||
|
||||
roll = x[1]
|
||||
|
||||
r, err = ParseRoll(roll)
|
||||
if err != nil {
|
||||
cmd.Session.ChannelMessageSend(cmd.Message.ChannelID, err.Error())
|
||||
return nil
|
||||
s.ChannelMessageSend(m.ChannelID, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
r.RollDice()
|
||||
@ -98,6 +127,5 @@ func RollCommand(cmd *bot.Command, args []string) error {
|
||||
|
||||
msg = fmt.Sprintf("🎲 %s = %d", lib.JoinInt(r.Rolls, " + "), r.Sum)
|
||||
|
||||
cmd.Session.ChannelMessageSend(cmd.Message.ChannelID, msg)
|
||||
return nil
|
||||
s.ChannelMessageSend(m.ChannelID, msg)
|
||||
}
|
37
bot/handler/ping.go
Normal file
37
bot/handler/ping.go
Normal file
@ -0,0 +1,37 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"git.kill0.net/chill9/beepboop/bot"
|
||||
"git.kill0.net/chill9/beepboop/lib"
|
||||
"github.com/bwmarrin/discordgo"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
type (
|
||||
PingHandler struct {
|
||||
config bot.Config
|
||||
Name string
|
||||
}
|
||||
)
|
||||
|
||||
func NewPingHandler(s string) *PingHandler {
|
||||
return &PingHandler{Name: s}
|
||||
}
|
||||
|
||||
func (h *PingHandler) SetConfig(config bot.Config) {
|
||||
h.config = config
|
||||
}
|
||||
|
||||
func (h *PingHandler) Handle(s *discordgo.Session, m *discordgo.MessageCreate) {
|
||||
if m.Author.ID == s.State.User.ID {
|
||||
return
|
||||
}
|
||||
|
||||
if !lib.ContainsCommand(m.Content, h.config.Prefix, h.Name) {
|
||||
return
|
||||
}
|
||||
|
||||
log.Debug("received ping")
|
||||
|
||||
s.ChannelMessageSend(m.ChannelID, "pong")
|
||||
}
|
@ -1,8 +1,11 @@
|
||||
package commands
|
||||
package handler
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"git.kill0.net/chill9/beepboop/bot"
|
||||
"git.kill0.net/chill9/beepboop/lib"
|
||||
"github.com/bwmarrin/discordgo"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
@ -18,6 +21,11 @@ type (
|
||||
C [6]bool
|
||||
N int
|
||||
}
|
||||
|
||||
RouletteHandler struct {
|
||||
config bot.Config
|
||||
Name string
|
||||
}
|
||||
)
|
||||
|
||||
var (
|
||||
@ -66,7 +74,23 @@ func (g *Gun) IsEmpty() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func RouletteCommand(cmd *bot.Command, args []string) error {
|
||||
func NewRouletteHandler(s string) *RouletteHandler {
|
||||
return &RouletteHandler{Name: s}
|
||||
}
|
||||
|
||||
func (h *RouletteHandler) SetConfig(config bot.Config) {
|
||||
h.config = config
|
||||
}
|
||||
|
||||
func (h *RouletteHandler) Handle(s *discordgo.Session, m *discordgo.MessageCreate) {
|
||||
if m.Author.ID == s.State.User.ID {
|
||||
return
|
||||
}
|
||||
|
||||
if !strings.HasPrefix(m.Content, "!roulette") {
|
||||
return
|
||||
}
|
||||
|
||||
if gun.IsEmpty() {
|
||||
gun.Load(Bullets)
|
||||
log.Debugf("reloading gun: %+v\n", gun)
|
||||
@ -74,9 +98,8 @@ func RouletteCommand(cmd *bot.Command, args []string) error {
|
||||
|
||||
log.Debugf("firing gun: %+v\n", gun)
|
||||
if gun.Fire() {
|
||||
cmd.Session.ChannelMessageSend(cmd.Message.ChannelID, GunFireMessage)
|
||||
s.ChannelMessageSend(m.ChannelID, GunFireMessage)
|
||||
} else {
|
||||
cmd.Session.ChannelMessageSend(cmd.Message.ChannelID, GunClickMessage)
|
||||
s.ChannelMessageSend(m.ChannelID, GunClickMessage)
|
||||
}
|
||||
return nil
|
||||
}
|
65
bot/handler/time.go
Normal file
65
bot/handler/time.go
Normal file
@ -0,0 +1,65 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.kill0.net/chill9/beepboop/bot"
|
||||
"github.com/bwmarrin/discordgo"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
type (
|
||||
TimeHandler struct {
|
||||
config bot.Config
|
||||
Name string
|
||||
}
|
||||
)
|
||||
|
||||
func NewTimeHandler(s string) *TimeHandler {
|
||||
return &TimeHandler{Name: s}
|
||||
}
|
||||
|
||||
func (h *TimeHandler) SetConfig(config bot.Config) {
|
||||
h.config = config
|
||||
}
|
||||
|
||||
func (h *TimeHandler) Handle(s *discordgo.Session, m *discordgo.MessageCreate) {
|
||||
var (
|
||||
t time.Time
|
||||
tz string
|
||||
)
|
||||
|
||||
if m.Author.ID == s.State.User.ID {
|
||||
return
|
||||
}
|
||||
|
||||
if !strings.HasPrefix(m.Content, "!time") {
|
||||
return
|
||||
}
|
||||
|
||||
x := strings.SplitN(m.Content, " ", 2)
|
||||
|
||||
if len(x) > 2 {
|
||||
s.ChannelMessageSend(m.ChannelID, "help: `!time TIMEZONE`")
|
||||
return
|
||||
}
|
||||
|
||||
now := time.Now()
|
||||
|
||||
if len(x) == 2 {
|
||||
tz = x[1]
|
||||
loc, err := time.LoadLocation(tz)
|
||||
if err != nil {
|
||||
log.Warnf("failed to load location: %s", err)
|
||||
s.ChannelMessageSend(m.ChannelID, err.Error())
|
||||
return
|
||||
}
|
||||
t = now.In(loc)
|
||||
} else {
|
||||
t = now
|
||||
}
|
||||
|
||||
s.ChannelMessageSend(m.ChannelID, fmt.Sprint(t))
|
||||
}
|
47
bot/handler/version.go
Normal file
47
bot/handler/version.go
Normal file
@ -0,0 +1,47 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"runtime"
|
||||
|
||||
"git.kill0.net/chill9/beepboop/bot"
|
||||
"git.kill0.net/chill9/beepboop/lib"
|
||||
"github.com/bwmarrin/discordgo"
|
||||
)
|
||||
|
||||
const (
|
||||
SourceURI = "https://git.kill0.net/chill9/bb"
|
||||
)
|
||||
|
||||
type (
|
||||
VersionHandler struct {
|
||||
config bot.Config
|
||||
Name string
|
||||
}
|
||||
)
|
||||
|
||||
func NewVersionHandler(s string) *VersionHandler {
|
||||
return &VersionHandler{Name: s}
|
||||
}
|
||||
|
||||
func (h *VersionHandler) SetConfig(config bot.Config) {
|
||||
h.config = config
|
||||
}
|
||||
|
||||
func (h *VersionHandler) Handle(s *discordgo.Session, m *discordgo.MessageCreate) {
|
||||
if m.Author.ID == s.State.User.ID {
|
||||
return
|
||||
}
|
||||
|
||||
if !lib.ContainsCommand(m.Content, h.config.Prefix, h.Name) {
|
||||
return
|
||||
}
|
||||
|
||||
s.ChannelMessageSend(m.ChannelID, fmt.Sprintf(
|
||||
"go version: %s\nplatform: %s\nos: %s\nsource: %s\n",
|
||||
runtime.Version(),
|
||||
runtime.GOARCH,
|
||||
runtime.GOOS,
|
||||
SourceURI,
|
||||
))
|
||||
}
|
@ -1,10 +1,12 @@
|
||||
package commands
|
||||
package handler
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"git.kill0.net/chill9/beepboop/bot"
|
||||
"git.kill0.net/chill9/beepboop/lib/weather"
|
||||
"github.com/bwmarrin/discordgo"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
@ -22,38 +24,48 @@ func (h *WeatherHandler) SetConfig(config bot.Config) {
|
||||
h.Config = config
|
||||
}
|
||||
|
||||
func WeatherCommand(cmd *bot.Command, args []string) error {
|
||||
func (h *WeatherHandler) Handle(s *discordgo.Session, m *discordgo.MessageCreate) {
|
||||
var (
|
||||
err error
|
||||
loc string
|
||||
w weather.Weather
|
||||
)
|
||||
|
||||
if len(args) != 1 {
|
||||
cmd.Session.ChannelMessageSend(cmd.Message.ChannelID, "help: `!weather <CITY>,<STATE>,<COUNTRY>`")
|
||||
return nil
|
||||
if m.Author.ID == s.State.User.ID {
|
||||
return
|
||||
}
|
||||
|
||||
loc = args[0]
|
||||
if !strings.HasPrefix(m.Content, "!weather") {
|
||||
return
|
||||
}
|
||||
|
||||
if cmd.Config.OpenWeatherMapToken == "" {
|
||||
x := strings.SplitN(m.Content, " ", 2)
|
||||
|
||||
if len(x) != 2 {
|
||||
s.ChannelMessageSend(m.ChannelID, "help: `!weather <CITY>,<STATE>,<COUNTRY>`")
|
||||
return
|
||||
}
|
||||
|
||||
loc = x[1]
|
||||
|
||||
if h.Config.OpenWeatherMapToken == "" {
|
||||
log.Error("OpenWeather token is not set")
|
||||
return nil
|
||||
return
|
||||
}
|
||||
|
||||
wc := weather.NewClient(cmd.Config.OpenWeatherMapToken)
|
||||
wc := weather.NewClient(h.Config.OpenWeatherMapToken)
|
||||
|
||||
log.Debugf("weather requested for '%s'", loc)
|
||||
|
||||
w, err = wc.Get(loc)
|
||||
if err != nil {
|
||||
log.Errorf("weather client error: %v", err)
|
||||
return nil
|
||||
return
|
||||
}
|
||||
|
||||
log.Debugf("weather returned for '%s': %+v", loc, w)
|
||||
|
||||
cmd.Session.ChannelMessageSend(cmd.Message.ChannelID, fmt.Sprintf(
|
||||
s.ChannelMessageSend(m.ChannelID, fmt.Sprintf(
|
||||
"%s (%.1f, %.1f) — C:%.1f F:%.1f K:%.1f",
|
||||
loc,
|
||||
w.Coord.Lat,
|
||||
@ -62,6 +74,4 @@ func WeatherCommand(cmd *bot.Command, args []string) error {
|
||||
w.Main.Temp.Fahrenheit(),
|
||||
w.Main.Temp.Kelvin(),
|
||||
))
|
||||
|
||||
return nil
|
||||
}
|
@ -11,7 +11,6 @@ import (
|
||||
"syscall"
|
||||
|
||||
"git.kill0.net/chill9/beepboop/bot"
|
||||
"git.kill0.net/chill9/beepboop/bot/commands"
|
||||
"git.kill0.net/chill9/beepboop/bot/handler"
|
||||
"git.kill0.net/chill9/beepboop/lib"
|
||||
|
||||
@ -25,41 +24,18 @@ var (
|
||||
C bot.Config
|
||||
|
||||
handlers []bot.MessageCreateHandler = []bot.MessageCreateHandler{
|
||||
handler.NewCoinHandler("coin"),
|
||||
handler.NewPingHandler("ping"),
|
||||
handler.NewRollHandler("roll"),
|
||||
handler.NewRouletteHandler("roulette"),
|
||||
handler.NewTimeHandler("time"),
|
||||
handler.NewVersionHandler("version"),
|
||||
handler.NewWeatherHandler("weather"),
|
||||
handler.NewReactionHandler(),
|
||||
handler.NewDealHandler("deal"),
|
||||
}
|
||||
)
|
||||
|
||||
func init() {
|
||||
bot.AddCommand(&bot.Command{
|
||||
Name: "coin",
|
||||
Func: commands.CoinCommand,
|
||||
})
|
||||
bot.AddCommand(&bot.Command{
|
||||
Name: "deal",
|
||||
Func: commands.DealCommand,
|
||||
})
|
||||
bot.AddCommand(&bot.Command{
|
||||
Name: "ping",
|
||||
Func: commands.PingCommand,
|
||||
})
|
||||
bot.AddCommand(&bot.Command{
|
||||
Name: "roll",
|
||||
Func: commands.RollCommand,
|
||||
})
|
||||
bot.AddCommand(&bot.Command{
|
||||
Name: "time",
|
||||
Func: commands.TimeCommand,
|
||||
})
|
||||
bot.AddCommand(&bot.Command{
|
||||
Name: "version",
|
||||
Func: commands.VersionCommand,
|
||||
})
|
||||
bot.AddCommand(&bot.Command{
|
||||
Name: "weather",
|
||||
Func: commands.WeatherCommand,
|
||||
})
|
||||
}
|
||||
|
||||
func main() {
|
||||
setupConfig()
|
||||
|
||||
@ -79,8 +55,6 @@ func main() {
|
||||
dg.AddHandler(h.Handle)
|
||||
}
|
||||
|
||||
dg.AddHandler(bot.NewCommandHandler(C))
|
||||
|
||||
dg.Identify.Intents = discordgo.IntentsGuildMessages | discordgo.IntentsDirectMessages
|
||||
|
||||
err = dg.Open()
|
||||
|
Loading…
Reference in New Issue
Block a user