diff --git a/cmd/bb/main.go b/cmd/bb/main.go index 67e06d3..4f51863 100644 --- a/cmd/bb/main.go +++ b/cmd/bb/main.go @@ -33,6 +33,7 @@ var ( command.NewPingHandler(), command.NewRollHandler(), command.NewRouletteHandler(), + command.NewSourceHandler(), command.NewTimeHandler(), command.NewWeatherHandler(), } diff --git a/command/source.go b/command/source.go new file mode 100644 index 0000000..98104bc --- /dev/null +++ b/command/source.go @@ -0,0 +1,37 @@ +package command + +import ( + "strings" + + "github.com/bwmarrin/discordgo" +) + +const ( + SourceURI = "https://git.kill0.net/chill9/bb" +) + +type ( + SourceHandler struct { + config Config + } +) + +func NewSourceHandler() *SourceHandler { + return new(SourceHandler) +} + +func (h *SourceHandler) SetConfig(config Config) { + h.config = config +} + +func (h *SourceHandler) Handle(s *discordgo.Session, m *discordgo.MessageCreate) { + if m.Author.ID == s.State.User.ID { + return + } + + if !strings.HasPrefix(m.Content, "!source") { + return + } + + s.ChannelMessageSend(m.ChannelID, SourceURI) +}