Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.IOException;
- import java.io.InputStream;
- import java.net.URL;
- import javax.servlet.ServletException;
- import javax.servlet.http.HttpServlet;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import net.keter.xeerbot.Bot;
- public class Main extends HttpServlet {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- Thread requester = new Thread(() -> run());
- public void run() {
- while (true) {
- try {
- sendBlank("https://keep-awake-bot.herokuapp.com/");
- System.out.println("Requested KeepAwake");
- } catch (Exception e) {
- }
- try {
- sendBlank("https://xeerbot.herokuapp.com/");
- System.out.println("Requested LiBot");
- } catch (Exception e) {
- }
- System.out.println("Requested WebService");
- try {
- Thread.sleep(60000);
- } catch (InterruptedException e) {
- System.out.println("Waiting interrupted!");
- }
- }
- }
- @Override
- protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- requester.start();
- req.getServletContext().setAttribute("running", true);
- resp.getWriter().println("Launched Xeerbot service!");
- try {
- Bot.main(null);
- } catch (Exception e) {
- e.printStackTrace(resp.getWriter());
- }
- }
- public static void sendBlank(String site) throws Exception {
- URL url = new URL(site);
- InputStream is = url.openStream();
- is.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment