|
|
|
@ -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 ( |
|
|
|
@ -31,18 +30,14 @@ 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(os.Args) <= 0 { |
|
|
|
|
println("Please add token as cli argument.") |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
dg, err := discordgo.New(fmt.Sprintf("Bot %s", token)) |
|
|
|
|
if err != nil { |
|
|
|
|
fmt.Println("error creating dicord bot: ", err) |
|
|
|
|
} |
|
|
|
|
dg, err := discordgo.New(fmt.Sprintf("Bot %s", os.Args[1])) |
|
|
|
|
canteens, err := openmensa.GetCanteens(175) |
|
|
|
|
if err != nil { |
|
|
|
|
fmt.Println("error getting mensa: ", err) |
|
|
|
|
fmt.Println("error creating discord bot: ", err) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
dg.AddHandler(messageCreate) |
|
|
|
|