diff --git a/.gitignore b/.gitignore index 282791f..58121c0 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,7 @@ *.pyc # Ignore secure config files: -config/secure.py +config/secure.cfg # Ignore pydev's nonsense: .project diff --git a/config/irc.py b/config/irc.py deleted file mode 100644 index ee9ef3e..0000000 --- a/config/irc.py +++ /dev/null @@ -1,25 +0,0 @@ -# -*- coding: utf-8 -*- - -# EarwigBot Configuration File -# This file contains information that the bot uses to connect to IRC. - -# our main (front-end) server's hostname and port -HOST = "irc.freenode.net" -PORT = 6667 - -# our watcher server's hostname, port, and RC channel -WATCHER_HOST = "irc.wikimedia.org" -WATCHER_PORT = 6667 -WATCHER_CHAN = "#en.wikipedia" - -# our nick, ident, and real name, used on both servers -NICK = "EarwigBot" -IDENT = "earwigbot" -REALNAME = "[[w:en:User:EarwigBot]]" - -# channels to join on main server's startup -CHANS = ["##earwigbot", "##earwig", "#wikipedia-en-afc"] - -# hardcoded hostnames of users with certain permissions -OWNERS = ["wikipedia/The-Earwig"] # can use owner-only commands (!restart and !git) -ADMINS = ["wikipedia/The-Earwig", "wikipedia/LeonardBloom"] # can use high-risk commands, e.g. !op diff --git a/config/__init__.py b/config/main.cfg similarity index 100% rename from config/__init__.py rename to config/main.cfg diff --git a/config/main.py b/config/main.py deleted file mode 100644 index 6e8c082..0000000 --- a/config/main.py +++ /dev/null @@ -1,24 +0,0 @@ -# -*- coding: utf-8 -*- - -# EarwigBot Configuration File -# This file tells the bot which of its components should be enabled. - -# The IRC frontend (configured in config/irc.py) sits on a public IRC network, -# responds to commands given to it, and reports edits (if the IRC watcher -# component is enabled). -enable_irc_frontend = True - -# The IRC watcher (connection details configured in config/irc.py as well) sits -# on an IRC network that gives a recent changes feed, usually irc.wikimedia.net. -# It looks for edits matching certain (often regex) patterns (rules configured -# in config/watcher.py), and either reports them to the IRC frontend (if -# enabled), or activates a task on the WikiBot (if configured to do). -enable_irc_watcher = True - -# EarwigBot doesn't have to edit a wiki, although this is its main purpose. If -# the wiki schedule is disabled, it will not be able to handle scheduled tasks -# that involve editing (such as creating a daily category every day at midnight -# UTC), but it can still edit through rules given in the watcher, and bot tasks -# can still be activated by the command line. The schedule is configured in -# config/schedule.py. -enable_wiki_schedule = True diff --git a/config/schedule.py b/config/schedule.py deleted file mode 100644 index 093050b..0000000 --- a/config/schedule.py +++ /dev/null @@ -1,28 +0,0 @@ -# -*- coding: utf-8 -*- - -# EarwigBot Configuration File -# This file tells the bot when to run certain wiki-editing tasks. - -def check(minute, hour, month_day, month, week_day): - tasks = [] # tasks to run this turn, each as a tuple of (task_name, kwargs) or just task_name - - if minute == 0: # run every hour on the hour - tasks.append(("afc_statistics", {"action": "save"})) # save statistics to [[Template:AFC_statistics]] - - if hour == 0: # run every day at midnight - tasks.append("afc_dailycats") # create daily categories for WP:AFC - tasks.append("feed_dailycats") # create daily categories for WP:FEED - - if week_day == 0: # run every Sunday at midnight (that is, the start of Sunday, not the end) - tasks.append("afc_undated") # clear [[Category:Undated AfC submissions]] - - if week_day == 1: # run every Monday at midnight - tasks.append("afc_catdelink") # delink mainspace categories in declined AfC submissions - - if week_day == 2: # run every Tuesday at midnight - tasks.append("wrongmime") # tag files whose extensions do not agree with their MIME type - - if week_day == 3: # run every Wednesday at midnight - tasks.append("blptag") # add |blp=yes to {{WPB}} or {{WPBS}} when it is used along with {{WP Biography}} - - return tasks diff --git a/config/secure.default.py b/config/secure.default.py deleted file mode 100644 index 0db882e..0000000 --- a/config/secure.default.py +++ /dev/null @@ -1,9 +0,0 @@ -# -*- coding: utf-8 -*- - -# EarwigBot Configuration File -# This file contains information that should be kept hidden, including passwords. - -# IRC: identify ourselves to NickServ? -NS_AUTH = False -NS_USER = "" -NS_PASS = "" diff --git a/config/watcher.py b/config/watcher.py deleted file mode 100644 index 6e2fe28..0000000 --- a/config/watcher.py +++ /dev/null @@ -1,69 +0,0 @@ -# -*- coding: utf-8 -*- - -# EarwigBot Configuration File -# This file contains rules for the bot's watcher component. - -import re - -from wiki import task_manager - -# Define different report channels on our front-end server. They /must/ be in CHANS in config/irc.py or the bot will not be able to send messages to them (unless they have -n set). -AFC_CHANS = ["#wikipedia-en-afc"] # report recent AfC changes/give AfC status messages upon join -BOT_CHANS = ["##earwigbot", "#wikipedia-en-afc"] # report edits containing "!earwigbot" - -# Define some commonly used strings. -afc_prefix = "wikipedia( talk)?:(wikiproject )?articles for creation" - -# Define our compiled regexps used when finding certain edits. -r_page = re.compile(afc_prefix) -r_ffu = re.compile("wikipedia( talk)?:files for upload") -r_move1 = re.compile("moved \[\[{}".format(afc_prefix)) # an AFC page was either moved locally or out -r_move2 = re.compile("moved \[\[(.*?)\]\] to \[\[{}".format(afc_prefix)) # an outside page was moved into AFC -r_moved_pages = re.compile("^moved \[\[(.*?)\]\] to \[\[(.*?)\]\]") -r_delete = re.compile("deleted \"\[\[{}".format(afc_prefix)) -r_deleted_page = re.compile("^deleted \"\[\[(.*?)\]\]") -r_restore = re.compile("restored \"\[\[{}".format(afc_prefix)) -r_restored_page = re.compile("^restored \"\[\[(.*?)\]\]") -r_protect = re.compile("protected \"\[\[{}".format(afc_prefix)) - -def process(rc): - chans = set() # channels to report this message to - page_name = rc.page.lower() - comment = rc.comment.lower() - - if "!earwigbot" in rc.msg.lower(): - chans.update(BOT_CHANS) - - if r_page.search(page_name): - task_manager.start_task("afc_statistics", action="process_edit", page=rc.page) - task_manager.start_task("afc_copyvios", action="process_edit", page=rc.page) - chans.update(AFC_CHANS) - - elif r_ffu.match(page_name): - chans.update(AFC_CHANS) - - elif page_name.startswith("template:afc submission"): - chans.update(AFC_CHANS) - - elif rc.flags == "move" and (r_move1.match(comment) or r_move2.match(comment)): - p = r_moved_pages.findall(rc.comment)[0] - task_manager.start_task("afc_statistics", action="process_move", pages=p) - task_manager.start_task("afc_copyvios", action="process_move", pages=p) - chans.update(AFC_CHANS) - - elif rc.flags == "delete" and r_delete.match(comment): - p = r_deleted_page.findall(rc.comment)[0][0] - task_manager.start_task("afc_statistics", action="process_delete", page=p) - task_manager.start_task("afc_copyvios", action="process_delete", page=p) - chans.update(AFC_CHANS) - - elif rc.flags == "restore" and r_restore.match(comment): - p = r_restored_page.findall(rc.comment)[0][0] - task_manager.start_task("afc_statistics", action="process_restore", page=p) - task_manager.start_task("afc_copyvios", action="process_restore", page=p) - chans.update(AFC_CHANS) - - elif rc.flags == "protect" and r_protect.match(comment): - chans.update(AFC_CHANS) - - return chans diff --git a/core/config.py b/core/config.py new file mode 100644 index 0000000..e69de29