JastRedd

Untitled

Sep 14th, 2017
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 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(new Runnable() {
  19.  
  20. @Override
  21. public void run() {
  22. while (true) {
  23.  
  24. try {
  25. sendBlank("https://keep-awake-bot.herokuapp.com/");
  26. System.out.println("Requested KeepAwake");
  27. } catch (Exception e) {
  28. }
  29. try {
  30. sendBlank("https://xeerbot.herokuapp.com/");
  31. System.out.println("Requested LiBot");
  32. } catch (Exception e) {
  33. }
  34. System.out.println("Requested WebService");
  35. try {
  36. Thread.sleep(60000);
  37. } catch (InterruptedException e) {
  38. System.out.println("Waiting interrupted!");
  39. }
  40.  
  41. }
  42. }
  43.  
  44. });
  45.  
  46. @Override
  47. protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
  48. try {
  49. requester.start();
  50. req.getServletContext().setAttribute("running", true);
  51. resp.getWriter().println("Launched Xeerbot service!");
  52. } catch (Exception e) {
  53. }
  54. try {
  55. Bot.main(null);
  56. } catch (Exception e) {
  57. e.printStackTrace(resp.getWriter());
  58. }
  59. }
  60.  
  61. public static void sendBlank(String site) throws Exception {
  62. URL url = new URL(site);
  63. InputStream is = url.openStream();
  64. is.close();
  65. }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment