Move config to bot package
This commit is contained in:
parent
cf3fece52c
commit
435884b61a
@ -1,4 +1,4 @@
|
||||
package command
|
||||
package bot
|
||||
|
||||
const (
|
||||
defaultPrefix = "!"
|
||||
@ -25,6 +25,10 @@ type (
|
||||
Emojis []string
|
||||
Channels []string
|
||||
}
|
||||
|
||||
WeatherConfig struct {
|
||||
Token string `mapstructure:"token"`
|
||||
}
|
||||
)
|
||||
|
||||
func NewConfig() Config {
|
@ -12,6 +12,7 @@ import (
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"git.kill0.net/chill9/beepboop/bot"
|
||||
"git.kill0.net/chill9/beepboop/command"
|
||||
"git.kill0.net/chill9/beepboop/lib"
|
||||
|
||||
@ -22,9 +23,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
defaultReactions []string = []string{"👍", "🌶️", "🤣", "😂", "🍆", "🍑", "❤️", "💦", "😍", "💩", "🔥", "🍒", "🎉", "🥳", "🎊"}
|
||||
|
||||
C command.Config
|
||||
C bot.Config
|
||||
|
||||
handlers []command.CommandHandler = []command.CommandHandler{
|
||||
command.NewCoinHandler(),
|
||||
@ -53,7 +52,6 @@ func main() {
|
||||
|
||||
lib.SeedMathRand()
|
||||
|
||||
viper.SetDefault("handler.reaction.emojis", defaultReactions)
|
||||
viper.SetEnvPrefix("BEEPBOOP")
|
||||
viper.AutomaticEnv()
|
||||
viper.SetConfigName("config")
|
||||
|
@ -1,8 +1,11 @@
|
||||
package command
|
||||
|
||||
import "github.com/bwmarrin/discordgo"
|
||||
import (
|
||||
"git.kill0.net/chill9/beepboop/bot"
|
||||
"github.com/bwmarrin/discordgo"
|
||||
)
|
||||
|
||||
type CommandHandler interface {
|
||||
Handle(s *discordgo.Session, m *discordgo.MessageCreate)
|
||||
SetConfig(config Config)
|
||||
SetConfig(config bot.Config)
|
||||
}
|
||||
|
@ -3,13 +3,14 @@ package command
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"git.kill0.net/chill9/beepboop/bot"
|
||||
"github.com/bwmarrin/discordgo"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
type (
|
||||
PingHandler struct {
|
||||
config Config
|
||||
config bot.Config
|
||||
}
|
||||
)
|
||||
|
||||
@ -17,7 +18,7 @@ func NewPingHandler() *PingHandler {
|
||||
return new(PingHandler)
|
||||
}
|
||||
|
||||
func (h *PingHandler) SetConfig(config Config) {
|
||||
func (h *PingHandler) SetConfig(config bot.Config) {
|
||||
h.config = config
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"git.kill0.net/chill9/beepboop/bot"
|
||||
"github.com/bwmarrin/discordgo"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
@ -35,14 +36,14 @@ type (
|
||||
}
|
||||
|
||||
CoinHandler struct {
|
||||
config Config
|
||||
config bot.Config
|
||||
}
|
||||
RollHandler struct {
|
||||
config Config
|
||||
config bot.Config
|
||||
}
|
||||
|
||||
RouletteHandler struct {
|
||||
config Config
|
||||
config bot.Config
|
||||
}
|
||||
)
|
||||
|
||||
@ -153,7 +154,7 @@ func NewRollHandler() *RollHandler {
|
||||
return new(RollHandler)
|
||||
}
|
||||
|
||||
func (h *RollHandler) SetConfig(config Config) {
|
||||
func (h *RollHandler) SetConfig(config bot.Config) {
|
||||
h.config = config
|
||||
}
|
||||
|
||||
@ -199,7 +200,7 @@ func NewRouletteHandler() *RouletteHandler {
|
||||
return new(RouletteHandler)
|
||||
}
|
||||
|
||||
func (h *RouletteHandler) SetConfig(config Config) {
|
||||
func (h *RouletteHandler) SetConfig(config bot.Config) {
|
||||
h.config = config
|
||||
}
|
||||
|
||||
@ -229,7 +230,7 @@ func NewCoinHandler() *CoinHandler {
|
||||
return new(CoinHandler)
|
||||
}
|
||||
|
||||
func (h *CoinHandler) SetConfig(config Config) {
|
||||
func (h *CoinHandler) SetConfig(config bot.Config) {
|
||||
h.config = config
|
||||
}
|
||||
|
||||
|
@ -5,13 +5,14 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.kill0.net/chill9/beepboop/bot"
|
||||
"github.com/bwmarrin/discordgo"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
type (
|
||||
TimeHandler struct {
|
||||
config Config
|
||||
config bot.Config
|
||||
}
|
||||
)
|
||||
|
||||
@ -19,7 +20,7 @@ func NewTimeHandler() *TimeHandler {
|
||||
return new(TimeHandler)
|
||||
}
|
||||
|
||||
func (h *TimeHandler) SetConfig(config Config) {
|
||||
func (h *TimeHandler) SetConfig(config bot.Config) {
|
||||
h.config = config
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"runtime"
|
||||
|
||||
"git.kill0.net/chill9/beepboop/bot"
|
||||
"github.com/bwmarrin/discordgo"
|
||||
)
|
||||
|
||||
@ -13,7 +14,7 @@ const (
|
||||
|
||||
type (
|
||||
VersionHandler struct {
|
||||
config Config
|
||||
config bot.Config
|
||||
Name string
|
||||
}
|
||||
)
|
||||
@ -24,7 +25,7 @@ func NewVersionHandler(s string) *VersionHandler {
|
||||
return h
|
||||
}
|
||||
|
||||
func (h *VersionHandler) SetConfig(config Config) {
|
||||
func (h *VersionHandler) SetConfig(config bot.Config) {
|
||||
h.config = config
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user