61 lines
1.4 KiB
Go
61 lines
1.4 KiB
Go
package main
|
|
|
|
import (
|
|
"ariona.fr/git/gator/gogodiscordo/core"
|
|
|
|
"log"
|
|
"os"
|
|
"os/signal"
|
|
"syscall"
|
|
|
|
"github.com/bwmarrin/discordgo"
|
|
)
|
|
|
|
func main() {
|
|
core.ConfigRegister.LoadConf()
|
|
discord, err := discordgo.New("Bot " + core.ConfigRegister.Token)
|
|
if err != nil {
|
|
log.Println("error creating Discord session, ", err)
|
|
return
|
|
}
|
|
|
|
core.SetCommand(
|
|
[]string{"/ggd audio", "/ggd tts"},
|
|
"*Attach a TTS version of the message on the channel*",
|
|
"`/ggd [audio|tts] hello everyone`",
|
|
core.MessageAudio)
|
|
core.SetCommand(
|
|
[]string{"ping", "pong"},
|
|
"*Check if the bot is alive*",
|
|
"`[ping|pong]`",
|
|
core.MessagePing)
|
|
core.SetCommand(
|
|
[]string{"/ggd help", "/ggd info"},
|
|
"*Display the available list of commands*",
|
|
"`/ggd [help|info]`",
|
|
core.MessageHelp)
|
|
core.SetCommand(
|
|
[]string{"/ggd hat", "/ggd chapeau", "/ggd chapo"},
|
|
"*Hand over a set of fancy hats*",
|
|
"`/ggd [hat|chapeau|chapo]`",
|
|
core.MessageHat)
|
|
|
|
discord.AddHandler(core.MessageHandler)
|
|
discord.AddHandler(core.MessageTalkback)
|
|
|
|
err = discord.Open()
|
|
if err != nil {
|
|
log.Println("error opening connection, ", err)
|
|
return
|
|
}
|
|
|
|
// Wait here until CTRL-C or other term signal is received.
|
|
log.Println("Bot is now running. Press CTRL-C to exit.")
|
|
sc := make(chan os.Signal, 1)
|
|
signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt, os.Kill)
|
|
<-sc
|
|
|
|
// Cleanly close down the Discord session.
|
|
discord.Close()
|
|
}
|