From 0c0204caa2bab00652115215bbb415b463472e84 Mon Sep 17 00:00:00 2001 From: pocketjawa Date: Sat, 27 Apr 2019 00:28:14 -0400 Subject: [PATCH] Added test flag to connect and the immediately disconnect. --- .drone.yml | 2 +- buttsbot.go | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.drone.yml b/.drone.yml index 60c040d..2024244 100644 --- a/.drone.yml +++ b/.drone.yml @@ -12,7 +12,7 @@ steps: commands: - go get - go build - - ./discord-buttsbot-go + - ./discord-buttsbot-go -test - name: discord image: appleboy/drone-discord settings: diff --git a/buttsbot.go b/buttsbot.go index 1cc264c..78a14a4 100644 --- a/buttsbot.go +++ b/buttsbot.go @@ -1,25 +1,26 @@ package main import ( - "fmt" "flag" + "fmt" + "github.com/bwmarrin/discordgo" "log" "os" "os/signal" "syscall" - "github.com/bwmarrin/discordgo" ) var Session, _ = discordgo.New() +var testPtr = flag.Bool("test", false, "Test mode") -func init(){ +func init() { Session.Token = os.Getenv("DISCORD_TOKEN") if Session.Token == "" { flag.StringVar(&Session.Token, "t", "", "Discord Authentication Token") } } -func main () { +func main() { var err error fmt.Println("butts!") flag.Parse() @@ -37,8 +38,13 @@ func main () { //Wait for a CTRL-C log.Printf("Now running. Press CTRL-C to exit.") + if *testPtr == true { + log.Printf("Test successful! Now quiting.") + Session.Close() + os.Exit(0) + } sc := make(chan os.Signal, 1) signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt, os.Kill) <-sc Session.Close() -} \ No newline at end of file +}