From bc75594704fdeedf32232c027d79e038d96da494 Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Sun, 13 May 2012 02:12:37 -0400 Subject: [PATCH] !pending --- earwigbot/commands/_old.py | 47 --------------------------------------- earwigbot/commands/afc_pending.py | 37 ++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 47 deletions(-) create mode 100644 earwigbot/commands/afc_pending.py diff --git a/earwigbot/commands/_old.py b/earwigbot/commands/_old.py index 64fcd74..a4e8fc1 100644 --- a/earwigbot/commands/_old.py +++ b/earwigbot/commands/_old.py @@ -131,10 +131,6 @@ def parse(command, line, line2, nick, chan, host, auth, notice, say, reply, s): msg = 'Can\'t find the etymology for "%s". Try %s' % (word, uri) reply(msg, chan, nick) return - if command == "pend" or command == "pending": - say("Pending submissions status page: .", chan) - say("Pending submissions category: .", chan) - return if command == "sub" or command == "submissions": try: number = int(line2[4]) @@ -191,49 +187,6 @@ def parse(command, line, line2, nick, chan, host, auth, notice, say, reply, s): else: reply("I refuse to hurt anything with \"Earwig\" in its name :P", chan, nick) return - if command == "mysql": - if authy != "owner": - reply("You aren't authorized to use this command.", chan, nick) - return - import MySQLdb - try: - strings = line2[4] - strings = ' '.join(line2[4:]) - if "db:" in strings: - database = re.findall("db\:(.*?)\s", strings)[0] - else: - database = "enwiki_p" - if "time:" in strings: - times = int(re.findall("time\:(.*?)\s", strings)[0]) - else: - times = 60 - file = re.findall("file\:(.*?)\s", strings)[0] - sqlquery = re.findall("query\:(.*?)\Z", strings)[0] - except Exception: - reply("You did not specify enough data for the bot to continue.", chan, nick) - return - database2 = database[:-2] + "-p" - db = MySQLdb.connect(db=database, host="%s.rrdb.toolserver.org" % database2, read_default_file="/home/earwig/.my.cnf") - db.query(sqlquery) - r = db.use_result() - data = r.fetch_row(0) - try: - f = codecs.open("/home/earwig/public_html/reports/%s/%s" % (database[:-2], file), 'r') - reply("A file already exists with that name.", chan, nick) - return - except Exception: - pass - f = codecs.open("/home/earwig/public_html/reports/%s/%s" % (database[:-2], file), 'a', 'utf-8') - for line in data: - new_line = [] - for l in line: - new_line.append(str(l)) - f.write(' '.join(new_line) + "\n") - f.close() - reply("Query completed successfully. See http://toolserver.org/~earwig/reports/%s/%s. I will delete the report in %s seconds." % (database[:-2], file, times), chan, nick) - time.sleep(times) - os.remove("/home/earwig/public_html/reports/%s/%s" % (database[:-2], file)) - return if command == "notes" or command == "note" or command == "about" or command == "data" or command == "database": try: action = line2[4] diff --git a/earwigbot/commands/afc_pending.py b/earwigbot/commands/afc_pending.py new file mode 100644 index 0000000..d90b25f --- /dev/null +++ b/earwigbot/commands/afc_pending.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- +# +# Copyright (C) 2009-2012 by Ben Kurtovic +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# 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. + +from earwigbot.commands import BaseCommand + +class Command(BaseCommand): + """Links the user to the pending AFC submissions page and category.""" + name = "pending" + + def check(self, data): + commands = ["pending", "pend"] + return data.is_command and data.command in commands + + def process(self, data): + msg1 = "pending submissions status page: http://enwp.org/WP:AFC/ST" + msg2 = "pending submissions category: http://enwp.org/CAT:PEND" + self.reply(data, msg1) + self.reply(data, msg2)