Jump to content

Wikipedia:Huggle/Extensions/huggle logs.py

Page extended-protected
From Wikipedia, the free encyclopedia

This extension will write to a log on your userpage everytime you request a deletion of some page. You can install it by copy pasting the code bellow and writing it as "huggle_log.py" to your extensions folder (by default ~/.local/shared/Wikimedia/Huggle/extensions on linux and AppData/Local/Wikimedia/Huggle/extensions on windows)

Bellow is a code of the extension:

#!/bin/echo This is a huggle extension, please use huggle instead
import huggle
import datetime

# this module will write to a log on wiki everytime you tag a page for speedy
wiki_log = "/CSD_log";
log_summary = "Logging speedy deletion nomination of [[$1]]";

def get_author():
    return "Petr Bena";
def get_version():
    return "1.0.0.0";
def get_description():
    return "This extension will write to " + wiki_log + " everytime you tag a page for speedy deletion";
def get_minimal_huggle_version():
    return "3.1.10";

# override the hook where we finish tagging a page
def hook_speedy_finished(page, user, tags, result):
    if (result != "success"):
        # there is nothing to do for us
        huggle.debug_log("Ignored unsuccessful tag of " + page + " (result was: " + result + ")", 1);
        return "";
    huggle.debug_log("logging " + page, 1);
    # let's get a name of page
    page_name = "User:" + huggle.configuration_get_user() + wiki_log;
    # create a summary
    summary = log_summary.replace("$1", page);
    # append this text to bottom of the page
    huggle.wikipage_append(page_name, "# [[" + page + "]] using <nowiki>" + tags + "</nowiki>; notified {{user|1=" + user + "}} " + 
                           str(datetime.datetime.now()) + "\n", summary);
    return "";