This repository has been archived on 2019-01-25. You can view files and clone it, but cannot push or open issues or pull requests.
Maerahn/src/main/java/eu/mikroskeem/bot/maerahn/commands/PartyHardCommand.java

49 lines
1.9 KiB
Java

package eu.mikroskeem.bot.maerahn.commands;
import eu.mikroskeem.bot.maerahn.Bot;
import org.slf4j.Logger;
import org.telegram.telegrambots.TelegramApiException;
import org.telegram.telegrambots.api.methods.send.SendMessage;
import org.telegram.telegrambots.api.objects.Chat;
import org.telegram.telegrambots.api.objects.User;
import org.telegram.telegrambots.bots.AbsSender;
import org.telegram.telegrambots.bots.commands.BotCommand;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
//
public class PartyHardCommand extends BotCommand {
private Random randomGenerator = new Random();
Logger logger;
private final List<String> partyhards = Arrays.asList(
"https://media.giphy.com/media/vg5ttW2Fx35zq/giphy.gif",
"http://www.gifbin.com/bin/012012/1338313384_russian_guy_dances_with_beer.gif",
"https://i.imgur.com/Wg5XVyK.gif",
"https://i.imgur.com/5jvCR2r.gif",
"https://i.imgur.com/zJklMAq.gif",
"https://i.imgur.com/qu2ksL6.gif",
"https://i.imgur.com/dO07YsQ.gif",
"https://i.imgur.com/huTAYeZ.gif",
"https://i.imgur.com/Jb4AABj.gif",
"https://i.imgur.com/htDE2vu.gif",
"https://i.imgur.com/ZpgiPx1.gif",
"https://i.imgur.com/giaQAlI.gif"
);
public PartyHardCommand(Bot bot){
super("partyhard", "Send random party hard gif");
logger = bot.logger;
}
@Override public void execute(AbsSender absSender, User user, Chat chat, String[] strings) {
SendMessage message = new SendMessage();
message.setChatId(chat.getId().toString());
message.setText(partyhards.get(randomGenerator.nextInt(partyhards.size())));
try {
absSender.sendMessage(message);
} catch (TelegramApiException e){
logger.error("Failed to send reply for /partyhard command!");
e.printStackTrace();
}
}
}