/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.techcavern.wavetact.ircCommands.dnsinfo;

import com.techcavern.wavetact.annot.IRCCMD;
import com.techcavern.wavetact.objects.IRCCommand;
import com.techcavern.wavetact.utils.GeneralUtils;
import com.techcavern.wavetact.utils.IRCUtils;
import com.techcavern.wavetact.utils.Registry;
import org.apache.commons.lang3.StringUtils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.pircbotx.Channel;
import org.pircbotx.PircBotX;
import org.pircbotx.User;
import org.xbill.DNS.*;

import java.util.Random;

/**
 * @author jztech101
 */
@IRCCMD
public class ISup extends IRCCommand {

    public ISup() {
        super(GeneralUtils.toArray("isup isupme"), 1, "isup [domain]", "Looks up a domain on isup.me to see if it is up", false);
    }

    @Override
    public void onCommand(String command, User user, PircBotX network, String prefix, Channel channel, boolean isPrivate, int userPermLevel, String... args) throws Exception {
        if (!args[0].startsWith("http://") && !args[0].startsWith("https://")) {
            args[0] = "http://" + args[0];
        }
        Document doc = Jsoup.connect("http://www.isup.me/" + args[0]).userAgent(Registry.USER_AGENT).get();
        String c = doc.select("#container").text();
        IRCUtils.sendMessage(user, network, channel, c, prefix);


    }

}


@@ -1425,24 +1425,557 @@
 r%22).text();%0A
+        if(c.contains(%22not just you%22))%7B%0A            c = %22It's not just you! %22 + args%5B0%5D + %22 looks down from here too. (Please note that isup.me - the service we use - lacks IPv6 support, so this might not be entirely accurate)%22;%0A        %7Delse if(c.contains(%22just you%22))%7B%0A            c = %22It's just you. %22 + args%5B0%5D + %22 looks fine from here.%22;%0A        %7Delse%7B%0A            c = %22isup.me can't find %22 + args%5B0%5D + %22 on the interwho. This might be because isup.me lacks IPv6 support or simply because you put in an invalid url.%22;%0A        %7D%0A
         IRCU

Add iSup.me command