Selaa lähdekoodia

Cleanup and updated go.mod

Mathew Medoff 3 vuotta sitten
vanhempi
commit
07bd120f5e
4 muutettua tiedostoa jossa 12 lisäystä ja 3 poistoa
  1. 5 2
      bot.go
  2. 1 0
      go.mod
  3. 6 0
      go.sum
  4. 0 1
      session.go

+ 5 - 2
bot.go

@@ -9,6 +9,7 @@ import (
 
 
 	"git.mgmcomp.net/thisnthat/discord/bot/event/mux"
 	"git.mgmcomp.net/thisnthat/discord/bot/event/mux"
 	"git.mgmcomp.net/thisnthat/discordgo"
 	"git.mgmcomp.net/thisnthat/discordgo"
+	"github.com/sirupsen/logrus"
 )
 )
 
 
 type Bot struct {
 type Bot struct {
@@ -21,7 +22,7 @@ type Bot struct {
 func (bot *Bot) AddHandler(handler interface{}) error {
 func (bot *Bot) AddHandler(handler interface{}) error {
 	// If the bot is online, we can not add a handler
 	// If the bot is online, we can not add a handler
 	if bot.online {
 	if bot.online {
-		err := fmt.Errorf("Unable to add handler to a bot that is already online")
+		err := fmt.Errorf("unable to add handler to a bot that is already online")
 		return err
 		return err
 	}
 	}
 
 
@@ -41,12 +42,14 @@ func (bot *Bot) Start(wg *sync.WaitGroup) error {
 		return err
 		return err
 	}
 	}
 
 
+	go logrus.Info("The bot has started")
 	bot.running = make(chan os.Signal, 1)
 	bot.running = make(chan os.Signal, 1)
 	bot.online = true
 	bot.online = true
-	signal.Notify(bot.running, syscall.SIGINT, os.Kill)
+	signal.Notify(bot.running, syscall.SIGINT, syscall.SIGTERM)
 	<-bot.running
 	<-bot.running
 
 
 	bot.session.Close()
 	bot.session.Close()
+	go logrus.Info("The bot has gone offline")
 	bot.online = false
 	bot.online = false
 
 
 	return nil
 	return nil

+ 1 - 0
go.mod

@@ -5,5 +5,6 @@ go 1.14
 require (
 require (
 	git.mgmcomp.net/thisnthat/discordgo v0.0.0-20211006203217-5322d32875f4
 	git.mgmcomp.net/thisnthat/discordgo v0.0.0-20211006203217-5322d32875f4
 	github.com/gorilla/websocket v1.4.2 // indirect
 	github.com/gorilla/websocket v1.4.2 // indirect
+	github.com/sirupsen/logrus v1.8.1
 	golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect
 	golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect
 )
 )

+ 6 - 0
go.sum

@@ -1,10 +1,16 @@
 git.mgmcomp.net/thisnthat/discordgo v0.0.0-20211006203217-5322d32875f4 h1:txbtCCEOuipIB0DgPubeTdw3igP+CR5Kl2gCKnYDf2M=
 git.mgmcomp.net/thisnthat/discordgo v0.0.0-20211006203217-5322d32875f4 h1:txbtCCEOuipIB0DgPubeTdw3igP+CR5Kl2gCKnYDf2M=
 git.mgmcomp.net/thisnthat/discordgo v0.0.0-20211006203217-5322d32875f4/go.mod h1:Mld4OR1WOQKeKYSMyYX3T18ilnCQCtwus+A1LoNcC50=
 git.mgmcomp.net/thisnthat/discordgo v0.0.0-20211006203217-5322d32875f4/go.mod h1:Mld4OR1WOQKeKYSMyYX3T18ilnCQCtwus+A1LoNcC50=
+github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
 github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
 github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
 github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
+github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
+github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
 golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg=
 golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg=
 golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
 golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
 golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
 golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
+golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 h1:SrN+KX8Art/Sf4HNj6Zcz06G7VEz+7w9tdXTPOZ7+l4=
 golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 h1:SrN+KX8Art/Sf4HNj6Zcz06G7VEz+7w9tdXTPOZ7+l4=
 golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=

+ 0 - 1
session.go

@@ -5,7 +5,6 @@ import "git.mgmcomp.net/thisnthat/discordgo"
 // GetSession - Get a discord session from the provided token
 // GetSession - Get a discord session from the provided token
 func GetSession(token string) (*discordgo.Session, error) {
 func GetSession(token string) (*discordgo.Session, error) {
 	session, err := discordgo.New("Bot " + token)
 	session, err := discordgo.New("Bot " + token)
-	session.Identify.Intents = discordgo.MakeIntent(discordgo.IntentsAll)
 
 
 	// If we can not create the client then just fatal.
 	// If we can not create the client then just fatal.
 	if err != nil {
 	if err != nil {