|
|
|
@ -2,13 +2,14 @@ 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 ( |
|
|
|
@ -28,11 +29,12 @@ var ( |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
func main() { |
|
|
|
|
if len(os.Args) <= 0 { |
|
|
|
|
token := os.Getenv("MENSABOT_TOKEN") |
|
|
|
|
if len(token) == 0 { |
|
|
|
|
println("Please add token as cli argument.") |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
dg, err := discordgo.New(fmt.Sprintf("Bot %s", os.Args[1])) |
|
|
|
|
dg, err := discordgo.New(fmt.Sprintf("Bot %s", token)) |
|
|
|
|
canteens, err := openmensa.GetCanteens(175) |
|
|
|
|
if err != nil { |
|
|
|
|
fmt.Println("error creating discord bot: ", err) |
|
|
|
@ -90,11 +92,12 @@ func sendMealsForDate(s *discordgo.Session, t time.Time, channel string) { |
|
|
|
|
for i, meal := range meals { |
|
|
|
|
prefix := "" |
|
|
|
|
|
|
|
|
|
outer: for emoji, keywords := range emojis { |
|
|
|
|
outer: |
|
|
|
|
for emoji, keywords := range emojis { |
|
|
|
|
for _, keyword := range keywords { |
|
|
|
|
if strings.Contains(strings.ToLower(meal.Name), keyword) { |
|
|
|
|
prefix += emoji |
|
|
|
|
continue outer; |
|
|
|
|
continue outer |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|