@@ -128,44 +128,6 @@ def parse(command, line, line2, nick, chan, host, auth, notice, say, reply, s): | |||||
return | return | ||||
if command == "sub" or command == "submissions": | |||||
try: | |||||
number = int(line2[4]) | |||||
except Exception: | |||||
reply("Please enter a number.", chan, nick) | |||||
return | |||||
do_url = False | |||||
try: | |||||
if "url" in line2[5:]: do_url = True | |||||
except Exception: | |||||
pass | |||||
url = "http://en.wikipedia.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:Pending_AfC_submissions&cmlimit=500&cmsort=timestamp" | |||||
query = urllib.urlopen(url) | |||||
data = query.read() | |||||
pages = re.findall("title="(.*?)"", data) | |||||
try: | |||||
pages.remove("Wikipedia:Articles for creation/Redirects") | |||||
except Exception: | |||||
pass | |||||
try: | |||||
pages.remove("Wikipedia:Files for upload") | |||||
except Exception: | |||||
pass | |||||
pages.reverse() | |||||
pages = pages[:number] | |||||
if not do_url: | |||||
s = string.join(pages, "]], [[") | |||||
s = "[[%s]]" % s | |||||
else: | |||||
s = string.join(pages, ">, <http://en.wikipedia.org/wiki/") | |||||
s = "<http://en.wikipedia.org/wiki/%s>" % s | |||||
s = re.sub(" ", "_", s) | |||||
s = re.sub(">,_<", ">, <", s) | |||||
report = "\x02First %s pending AfC submissions:\x0F %s" % (number, s) | |||||
say(report, chan) | |||||
return | |||||
if command == "trout": | if command == "trout": | ||||
try: | try: | ||||
user = line2[4] | user = line2[4] | ||||
@@ -47,6 +47,7 @@ class Command(BaseCommand): | |||||
return | return | ||||
safe = quote_plus(user.name) | safe = quote_plus(user.name) | ||||
url = "http://toolserver.org/~tparis/pcount/index.php?name={0}&lang=en&wiki=wikipedia" | |||||
url = "http://toolserver.org/~tparis/pcount/index.php?name={0}&lang={1}&wiki={2}" | |||||
fullurl = url.format(safe, site.lang, site.project) | |||||
msg = "\x0302{0}\x0301 has {1} edits ({2})." | msg = "\x0302{0}\x0301 has {1} edits ({2})." | ||||
self.reply(data, msg.format(name, count, url.format(safe))) | |||||
self.reply(data, msg.format(name, count, fullurl)) |
@@ -30,10 +30,12 @@ class Command(BaseCommand): | |||||
"""Commands to interface with the bot's git repository; use '!git' for a | """Commands to interface with the bot's git repository; use '!git' for a | ||||
sub-command list.""" | sub-command list.""" | ||||
name = "git" | name = "git" | ||||
repos = { | |||||
"core": "/home/earwig/git/earwigbot", | |||||
"plugins": "/home/earwig/git/earwigbot-plugins", | |||||
} | |||||
def setup(self): | |||||
try: | |||||
self.repos = self.config.commands[self.name]["repos"] | |||||
except KeyError: | |||||
self.repos = None | |||||
def process(self, data): | def process(self, data): | ||||
self.data = data | self.data = data | ||||
@@ -44,6 +46,9 @@ class Command(BaseCommand): | |||||
if not data.args or data.args[0] == "help": | if not data.args or data.args[0] == "help": | ||||
self.do_help() | self.do_help() | ||||
return | return | ||||
if not self.repos: | |||||
self.reply(data, "no repos are specified in the config file.") | |||||
return | |||||
command = data.args[0] | command = data.args[0] | ||||
try: | try: | ||||
@@ -55,7 +60,7 @@ class Command(BaseCommand): | |||||
return | return | ||||
if repo_name not in self.repos: | if repo_name not in self.repos: | ||||
repos = self.get_repos() | repos = self.get_repos() | ||||
msg = "repository must be one of the following: {0}" | |||||
msg = "repository must be one of the following: {0}." | |||||
self.reply(data, msg.format(repos)) | self.reply(data, msg.format(repos)) | ||||
return | return | ||||
self.repo = git.Repo(self.repos[repo_name]) | self.repo = git.Repo(self.repos[repo_name]) | ||||
@@ -89,7 +94,7 @@ class Command(BaseCommand): | |||||
try: | try: | ||||
return getattr(self.repo.remotes, remote_name) | return getattr(self.repo.remotes, remote_name) | ||||
except AttributeError: | except AttributeError: | ||||
msg = "unknown remote: \x0302{0}\x0301".format(remote_name) | |||||
msg = "unknown remote: \x0302{0}\x0301.".format(remote_name) | |||||
self.reply(self.data, msg) | self.reply(self.data, msg) | ||||
def get_time_since(self, date): | def get_time_since(self, date): | ||||
@@ -54,7 +54,7 @@ class Command(BaseCommand): | |||||
elif user.gender == "female": | elif user.gender == "female": | ||||
gender = "She's" | gender = "She's" | ||||
else: | else: | ||||
gender = "They're" | |||||
gender = "They're" # Singluar they? | |||||
msg = "\x0302{0}\x0301 registered on {1}. {2} {3} old." | msg = "\x0302{0}\x0301 registered on {1}. {2} {3} old." | ||||
self.reply(data, msg.format(name, date, gender, age)) | self.reply(data, msg.format(name, date, gender, age)) | ||||
@@ -30,10 +30,16 @@ class Command(BaseCommand): | |||||
"""Return the replag for a specific database on the Toolserver.""" | """Return the replag for a specific database on the Toolserver.""" | ||||
name = "replag" | name = "replag" | ||||
def setup(self): | |||||
try: | |||||
self.key = self.config.commands[self.name]["default"] | |||||
except KeyError: | |||||
self.default = None | |||||
def process(self, data): | def process(self, data): | ||||
args = {} | args = {} | ||||
if not data.args: | if not data.args: | ||||
args["db"] = "enwiki_p" | |||||
args["db"] = self.default or self.bot.wiki.get_site().name + "_p" | |||||
else: | else: | ||||
args["db"] = data.args[0] | args["db"] = data.args[0] | ||||
args["host"] = args["db"].replace("_", "-") + ".rrdb.toolserver.org" | args["host"] = args["db"].replace("_", "-") + ".rrdb.toolserver.org" | ||||
@@ -47,5 +53,5 @@ class Command(BaseCommand): | |||||
replag = int(cursor.fetchall()[0][0]) | replag = int(cursor.fetchall()[0][0]) | ||||
conn.close() | conn.close() | ||||
msg = "Replag on \x0302{0}\x0301 is \x02{1}\x0F seconds." | |||||
msg = "replag on \x0302{0}\x0301 is \x02{1}\x0F seconds." | |||||
self.reply(data, msg.format(args["db"], replag)) | self.reply(data, msg.format(args["db"], replag)) |