Advertisement
Cool_boy21

Untitled

Mar 6th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.94 KB | None | 0 0
  1. private void cat(Update update) {
  2.         if (isPlaycraft(update)) {
  3.             return;
  4.         }
  5.         exec.submit(() -> {
  6.             try {
  7.                 String response = Util.readStream(Util.makeRequest("http://random.cat/meow"));
  8.                 Map json = new Gson().fromJson(response, Map.class);
  9.                 String url = (String) json.get("file");
  10.                 if (url.endsWith(".gif")) {
  11.                     SendDocument gif = new SendDocument().setNewDocument("Cat.gif", Util.makeRequest(url)).setChatId(update.getMessage().getChatId());
  12.                     bot.sendDocument(gif);
  13.                 } else {
  14.                     SendPhoto photo = new SendPhoto().setNewPhoto("Cat", Util.makeRequest(url)).setChatId(update.getMessage().getChatId());
  15.                     bot.sendPhoto(photo);
  16.                 }
  17.             } catch (Exception ex) {
  18.                 Logs.error("Failed to send cat");
  19.             }
  20.         });
  21.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement