Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void cat(Update update) {
- if (isPlaycraft(update)) {
- return;
- }
- exec.submit(() -> {
- try {
- String response = Util.readStream(Util.makeRequest("http://random.cat/meow"));
- Map json = new Gson().fromJson(response, Map.class);
- String url = (String) json.get("file");
- if (url.endsWith(".gif")) {
- SendDocument gif = new SendDocument().setNewDocument("Cat.gif", Util.makeRequest(url)).setChatId(update.getMessage().getChatId());
- bot.sendDocument(gif);
- } else {
- SendPhoto photo = new SendPhoto().setNewPhoto("Cat", Util.makeRequest(url)).setChatId(update.getMessage().getChatId());
- bot.sendPhoto(photo);
- }
- } catch (Exception ex) {
- Logs.error("Failed to send cat");
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement