Search in sources :

Example 1 with Restaurant

use of org.wyvie.chehov.bot.commands.dailymenu.restaurant.Restaurant in project anton-pavlovich-bot by wyvie.

the class DailyMenuCommandHandler method handle.

@Override
public void handle(Message message, String args) {
    logger.debug("args is '" + args + "'");
    int dayOfWeek = LocalDateTime.now().getDayOfWeek().getValue();
    if (dayOfWeek > 5) {
        SendMessage sendMessage = new SendMessage(message.chat().id(), "Only available on week days.");
        telegramBot.execute(sendMessage);
        return;
    }
    Restaurant restaurant = restaurantMap.get(args);
    String textToSend;
    if (restaurant == null) {
        textToSend = "Please specify one of the following restaurants:\n";
        StringBuilder sb = new StringBuilder("");
        restaurantMap.forEach((k, v) -> {
            if (sb.length() > 0)
                sb.append(", ");
            sb.append(k);
        });
        textToSend += sb.toString();
    } else {
        textToSend = restaurant.menu();
        if (StringUtils.isEmpty(textToSend))
            textToSend = "Something went wrong. I could not fetch menu for you." + "I am so very, very sorry. :'(";
    }
    SendMessage sendMessage = new SendMessage(message.chat().id(), textToSend);
    telegramBot.execute(sendMessage);
}
Also used : Restaurant(org.wyvie.chehov.bot.commands.dailymenu.restaurant.Restaurant) SendMessage(com.pengrad.telegrambot.request.SendMessage)

Aggregations

SendMessage (com.pengrad.telegrambot.request.SendMessage)1 Restaurant (org.wyvie.chehov.bot.commands.dailymenu.restaurant.Restaurant)1