Added test flag to connect and the immediately disconnect.
parent
8afc7ffa58
commit
0c0204caa2
|
@ -12,7 +12,7 @@ steps:
|
||||||
commands:
|
commands:
|
||||||
- go get
|
- go get
|
||||||
- go build
|
- go build
|
||||||
- ./discord-buttsbot-go
|
- ./discord-buttsbot-go -test
|
||||||
- name: discord
|
- name: discord
|
||||||
image: appleboy/drone-discord
|
image: appleboy/drone-discord
|
||||||
settings:
|
settings:
|
||||||
|
|
16
buttsbot.go
16
buttsbot.go
|
@ -1,25 +1,26 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"flag"
|
"flag"
|
||||||
|
"fmt"
|
||||||
|
"github.com/bwmarrin/discordgo"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"syscall"
|
"syscall"
|
||||||
"github.com/bwmarrin/discordgo"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var Session, _ = discordgo.New()
|
var Session, _ = discordgo.New()
|
||||||
|
var testPtr = flag.Bool("test", false, "Test mode")
|
||||||
|
|
||||||
func init(){
|
func init() {
|
||||||
Session.Token = os.Getenv("DISCORD_TOKEN")
|
Session.Token = os.Getenv("DISCORD_TOKEN")
|
||||||
if Session.Token == "" {
|
if Session.Token == "" {
|
||||||
flag.StringVar(&Session.Token, "t", "", "Discord Authentication Token")
|
flag.StringVar(&Session.Token, "t", "", "Discord Authentication Token")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func main () {
|
func main() {
|
||||||
var err error
|
var err error
|
||||||
fmt.Println("butts!")
|
fmt.Println("butts!")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
@ -37,8 +38,13 @@ func main () {
|
||||||
|
|
||||||
//Wait for a CTRL-C
|
//Wait for a CTRL-C
|
||||||
log.Printf("Now running. Press CTRL-C to exit.")
|
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)
|
sc := make(chan os.Signal, 1)
|
||||||
signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt, os.Kill)
|
signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt, os.Kill)
|
||||||
<-sc
|
<-sc
|
||||||
Session.Close()
|
Session.Close()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue