# Path: core/moduletemplate.py
# class BotModule:
#     PRIV_NONE = "none"
#     PRIV_MOD = "mod"
#     PRIV_MODERATOR = "mod"
#     PRIV_ADMIN = "admin"
#     PRIV_ADMINISTRATOR = "admin"
#     def __init__(self, conn, logger, module_name):
#     def on_module_load(self):
#     def on_module_unload(self):
#     def on_connect(self):
#     def on_disconnect(self):
#     def on_privmsg(self, target, nick, message):
#     def on_action(self, target, nick, action):
#     def on_join(self, nick, channel):
#     def on_part(self, nick, channel, message):
#     def on_self_join(self, channel):
#     def on_self_part(self, channel):
#     def on_kick(self, nick, channel, knick, reason):
#     def on_quit(self, nick, message):
#     def on_command(self, target, nick, command, commandtext, mod, admin):
#     def on_numeric(self, numeric, data):
#     def message(self, target, nick, message, parse=False):
#     def notice(self, nick, message, parse=False):
#     def action(self, target, action, parse=False):
#     def mode(self, target, modes):
#     def ban(self, nick, channel, quiet=False):
#     def getMask(self, nick):
#     def send_raw(self, raw_message):
#     def debug(self, message, format=False):
#     def log(self, message):
#     def log_verbose(self, message):
#     def warning(self, message):
#     def notice_verbose(self, message):
#     def warning_verbose(self, message):
#     def error(self, message):
#     def isOp(self, nick, channel):
#     def isVoice(self, nick, channel):
#     def isOn(self, nick, channel):
#     def isIdentified(self, nick):
#     def isOper(self, nick):
#     def getUserData(self, nick):
#     def getChannelData(self, channel):
#     def isBotAdministrator(self, nick):
#     def isBotModerator(self, nick):
#     def ratelimit(self, command, confName="rate_limit_delay", delay=10):
#     def register_command(self, command, params, help, priv, aliases=None):
#     def unregister_command(self, command):
#     def getConfigMetadata(self, metadata):
#     def requireApiKey(self, api_name):
#     def _getApiKey(self, api_name):
#     def _unregister_commands(self):
#     def _getModuleData(self):
# 
# Path: tools/urlparse.py
# RE_PROTOCOL = r"(?:([\w\-_]+?)(?::\/\/))?"  # (1) match the protocol, strip :// e.g. https or ssh
# RE_DOMAIN = r"([\w\-_\.]+)"  # (2) match the domain, and any subdomains. e.g. www.google, google, or maps.google
# RE_TLD = r"\.([a-z]{2,16})"  # (3) The top level domain, does not account for unicode. e.g. com, info, org
# RE_PORT = r"(?::(\+?[1-9]\d{1,4}))?"  # (4) The port. e.g. google.com:100 extracts 100
# RE_PATH = r"(\/[^ ]+)?"  # (5) Get everything after the top level domain / port starting with a slash. e.g. /hi.html
# URL_REGEX = re.compile(RE_PROTOCOL + RE_DOMAIN + RE_TLD + RE_PORT + RE_PATH, re.I)
#     CERTAINTY_CAP = 100
# class Url:
#     def __init__(self, url, min_certainty=50):
#     def getCertainty(self):
#     def getMinCertainty(self):
#     def getUrl(self):
#     def getProtocol(self):
#     def getSubdomains(self):
#     def getDomain(self):
#     def getPort(self):
#     def getTld(self):
#     def getPath(self):
#     def getFactors(self):
#     def getAsDict(self):
#     def find(string):
#     def findAll(string):
#     def isUrl(self):
#     def encode(self):
#     def decode(self):
#     def _parse(self):
#     def _calculateCertainty(self):
#     def _addCertainty(self, amount, factor):


from core import moduletemplate
from tools import urlparse
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Debug URLs by Zarthus
Licensed under MIT
"""



class UrlDebug(moduletemplate.BotModule):

    def on_module_load(self):
        self.register_command("isurl", "<url>", "Validate an URL through the Url class.", self.PRIV_ADMIN)
        self.register_command("findurl", "<url>", "Validate an URL through the Url class.", self.PRIV_ADMIN)
        self.register_command("dumpurl", "<url>", "Dump information about an URL", self.PRIV_ADMIN)
        self.register_command("urlstring", "<string>", "Validate multiple URLs through the Url class.",
                              self.PRIV_ADMIN)

    def on_command(self, target, nick, command, commandtext, mod, admin):
        if admin:
            if command == "isurl":
                if not commandtext:
                    return self.notice(nick, "Usage: isurl <url>")

                link = commandtext


# Path: core/moduletemplate.py
# class BotModule:
#     PRIV_NONE = "none"
#     PRIV_MOD = "mod"
#     PRIV_MODERATOR = "mod"
#     PRIV_ADMIN = "admin"
#     PRIV_ADMINISTRATOR = "admin"
#     def __init__(self, conn, logger, module_name):
#     def on_module_load(self):
#     def on_module_unload(self):
#     def on_connect(self):
#     def on_disconnect(self):
#     def on_privmsg(self, target, nick, message):
#     def on_action(self, target, nick, action):
#     def on_join(self, nick, channel):
#     def on_part(self, nick, channel, message):
#     def on_self_join(self, channel):
#     def on_self_part(self, channel):
#     def on_kick(self, nick, channel, knick, reason):
#     def on_quit(self, nick, message):
#     def on_command(self, target, nick, command, commandtext, mod, admin):
#     def on_numeric(self, numeric, data):
#     def message(self, target, nick, message, parse=False):
#     def notice(self, nick, message, parse=False):
#     def action(self, target, action, parse=False):
#     def mode(self, target, modes):
#     def ban(self, nick, channel, quiet=False):
#     def getMask(self, nick):
#     def send_raw(self, raw_message):
#     def debug(self, message, format=False):
#     def log(self, message):
#     def log_verbose(self, message):
#     def warning(self, message):
#     def notice_verbose(self, message):
#     def warning_verbose(self, message):
#     def error(self, message):
#     def isOp(self, nick, channel):
#     def isVoice(self, nick, channel):
#     def isOn(self, nick, channel):
#     def isIdentified(self, nick):
#     def isOper(self, nick):
#     def getUserData(self, nick):
#     def getChannelData(self, channel):
#     def isBotAdministrator(self, nick):
#     def isBotModerator(self, nick):
#     def ratelimit(self, command, confName="rate_limit_delay", delay=10):
#     def register_command(self, command, params, help, priv, aliases=None):
#     def unregister_command(self, command):
#     def getConfigMetadata(self, metadata):
#     def requireApiKey(self, api_name):
#     def _getApiKey(self, api_name):
#     def _unregister_commands(self):
#     def _getModuleData(self):
# 
# Path: tools/urlparse.py
# RE_PROTOCOL = r"(?:([\w\-_]+?)(?::\/\/))?"  # (1) match the protocol, strip :// e.g. https or ssh
# RE_DOMAIN = r"([\w\-_\.]+)"  # (2) match the domain, and any subdomains. e.g. www.google, google, or maps.google
# RE_TLD = r"\.([a-z]{2,16})"  # (3) The top level domain, does not account for unicode. e.g. com, info, org
# RE_PORT = r"(?::(\+?[1-9]\d{1,4}))?"  # (4) The port. e.g. google.com:100 extracts 100
# RE_PATH = r"(\/[^ ]+)?"  # (5) Get everything after the top level domain / port starting with a slash. e.g. /hi.html
# URL_REGEX = re.compile(RE_PROTOCOL + RE_DOMAIN + RE_TLD + RE_PORT + RE_PATH, re.I)
#     CERTAINTY_CAP = 100
# class Url:
#     def __init__(self, url, min_certainty=50):
#     def getCertainty(self):
#     def getMinCertainty(self):
#     def getUrl(self):
#     def getProtocol(self):
#     def getSubdomains(self):
#     def getDomain(self):
#     def getPort(self):
#     def getTld(self):
#     def getPath(self):
#     def getFactors(self):
#     def getAsDict(self):
#     def find(string):
#     def findAll(string):
#     def isUrl(self):
#     def encode(self):
#     def decode(self):
#     def _parse(self):
#     def _calculateCertainty(self):
#     def _addCertainty(self, amount, factor):


# Path: modules_disabled/debug_url.py
from core import moduletemplate
from tools import urlparse

IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Debug URLs by Zarthus
Licensed under MIT
"""



class UrlDebug(moduletemplate.BotModule):

    def on_module_load(self):
        self.register_command("isurl", "<url>", "Validate an URL through the Url class.", self.PRIV_ADMIN)
        self.register_command("findurl", "<url>", "Validate an URL through the Url class.", self.PRIV_ADMIN)
        self.register_command("dumpurl", "<url>", "Dump information about an URL", self.PRIV_ADMIN)
        self.register_command("urlstring", "<string>", "Validate multiple URLs through the Url class.",
                              self.PRIV_ADMIN)

    def on_command(self, target, nick, command, commandtext, mod, admin):
        if admin:
            if command == "isurl":
                if not commandtext:
                    return self.notice(nick, "Usage: isurl <url>")

                link = commandtext


                urlclass = urlparse.Url(link)