JastRedd

Untitled

Sep 14th, 2017
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. import java.io.IOException;
  2. import java.io.InputStream;
  3. import java.net.URL;
  4.  
  5. import javax.servlet.ServletException;
  6. import javax.servlet.http.HttpServlet;
  7. import javax.servlet.http.HttpServletRequest;
  8. import javax.servlet.http.HttpServletResponse;
  9.  
  10. import net.keter.xeerbot.Bot;
  11.  
  12. public class Main extends HttpServlet {
  13. /**
  14. *
  15. */
  16. private static final long serialVersionUID = 1L;
  17.  
  18. Thread requester = new Thread(() -> run());
  19.  
  20. public void run() {
  21. while (true) {
  22.  
  23. try {
  24. sendBlank("https://keep-awake-bot.herokuapp.com/");
  25. System.out.println("Requested KeepAwake");
  26. } catch (Exception e) {
  27. }
  28. try {
  29. sendBlank("https://xeerbot.herokuapp.com/");
  30. System.out.println("Requested LiBot");
  31. } catch (Exception e) {
  32. }
  33. System.out.println("Requested WebService");
  34. try {
  35. Thread.sleep(60000);
  36. } catch (InterruptedException e) {
  37. System.out.println("Waiting interrupted!");
  38. }
  39.  
  40. }
  41. }
  42.  
  43. @Override
  44. protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
  45.  
  46. requester.start();
  47. req.getServletContext().setAttribute("running", true);
  48. resp.getWriter().println("Launched Xeerbot service!");
  49.  
  50. try {
  51. Bot.main(null);
  52. } catch (Exception e) {
  53. e.printStackTrace(resp.getWriter());
  54. }
  55. }
  56.  
  57. public static void sendBlank(String site) throws Exception {
  58. URL url = new URL(site);
  59. InputStream is = url.openStream();
  60. is.close();
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment