Sync files with github #5

Merged
JonasFranzDEV merged 3 commits from kolaente/mensabot:github-sync into master 5 years ago
  1. 17
      bot.go

@ -2,14 +2,13 @@ package main
import ( import (
"fmt" "fmt"
"github.com/bwmarrin/discordgo"
"github.com/kiliankoe/openmensa"
"os" "os"
"os/signal" "os/signal"
"strings" "strings"
"syscall" "syscall"
"time" "time"
"github.com/bwmarrin/discordgo"
"github.com/kiliankoe/openmensa"
) )
var ( var (
@ -32,13 +31,19 @@ var (
func main() { func main() {
token := os.Getenv("MENSABOT_TOKEN") token := os.Getenv("MENSABOT_TOKEN")
if len(token) == 0 || token == "token" { if len(token) == 0 || token == "token" || len(os.Args) <= 0 {
println("Please add token as environment variable: MENSABOT_TOKEN.") println("Please add token as environment variable (MENSABOT_TOKEN) or cli argument.")
return return
} }
if len(os.Args) > 0 {
token = os.Args[0]
}
dg, err := discordgo.New(fmt.Sprintf("Bot %s", token)) dg, err := discordgo.New(fmt.Sprintf("Bot %s", token))
if err != nil { if err != nil {
fmt.Println("error creating dicord bot: ", err) fmt.Println("error creating discord bot: ", err)
return
} }
canteens, err := openmensa.GetCanteens(175) canteens, err := openmensa.GetCanteens(175)
if err != nil { if err != nil {

Loading…
Cancel
Save