Huggle/JS/hanguard.js

From MediaWiki.org
< Huggle‎ | JS
Jump to navigation Jump to search
// This extension will check HAN (IRC network) and block all requests
// per configuration:

var disable_all_revert = false;
var disable_all_rescore = false;
var disable_all_suspicious = false;
var disable_all_good = false;
var rescoring_hosts = [ "EFBC1D29:FAA53D66:7318183F:IP", "cluebot.huggle" ];

function ext_is_working()
{
    return true;
}

function on_good(edit, nick, ident)
{
    if (disable_all_good)
        return false;
    return true;
}

function on_revert(edit, nick, ident, host)
{
    if (disable_all_revert)
        return false;
    return true;
}

function on_susp(edit, nick, ident, host)
{
    if (disable_all_suspicious)
        return false;
    return true;
}

function on_rescore(edit, score, nick, ident, host)
{
    if (disable_all_rescore)
        return false;
    if (!rescoring_hosts.contains(host))
    {
        huggle.warning_log("Ignoring rescoring HAN message from: " + host);
        return false;
    }
    return true;
}

function ext_init()
{
    if (!huggle.register_hook("han_good", "on_good") ||
        !huggle.register_hook("han_revert", "on_revert") ||
        !huggle.register_hook("han_suspicious", "on_susp") ||
        !huggle.register_hook("han_rescore", "on_rescore"))
    {
        // Unable to register hooks
        huggle.error_log("Unable to register hooks");
        return false;
    }
    return true;
}

function ext_get_info()
{
    var info = {};
    info["name"] = "hanguard";
    info["version"] = "1.0.0";
    info["description"] = "Protects HAN from hackers";
    info["author"] = "Petr Bena";
    info["min_huggle_version"] = "3.4.5";
    // info["required_context"] = "huggle_ui";
    // info["requires_unsafe"] = false;
    return info;
}