Browse Source

Sync files with github (#5)

pull/6/head
kolaente 3 years ago committed by Gitea
parent
commit
3fc9fd5dcb
  1. 17
      bot.go

17
bot.go

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

Loading…
Cancel
Save