Browse Source

Substitute \x0301 with \x0F for returning to "normal" colors.

tags/v0.1^2
Ben Kurtovic 12 years ago
parent
commit
b42389d393
11 changed files with 55 additions and 55 deletions
  1. +5
    -5
      earwigbot/commands/afc_report.py
  2. +14
    -14
      earwigbot/commands/afc_status.py
  3. +2
    -2
      earwigbot/commands/geolocate.py
  4. +15
    -15
      earwigbot/commands/git.py
  5. +2
    -2
      earwigbot/commands/help.py
  6. +2
    -2
      earwigbot/commands/langcode.py
  7. +2
    -2
      earwigbot/commands/registration.py
  8. +1
    -1
      earwigbot/commands/replag.py
  9. +2
    -2
      earwigbot/commands/rights.py
  10. +9
    -9
      earwigbot/commands/threads.py
  11. +1
    -1
      earwigbot/irc/connection.py

+ 5
- 5
earwigbot/commands/afc_report.py View File

@@ -66,7 +66,7 @@ class AFCReport(Command):
if page: if page:
return self.report(page) return self.report(page)


self.reply(data, "submission \x0302{0}\x0301 not found.".format(title))
self.reply(data, "submission \x0302{0}\x0F not found.".format(title))


def get_page(self, title): def get_page(self, title):
page = self.site.get_page(title, follow_redirects=False) page = self.site.get_page(title, follow_redirects=False)
@@ -81,11 +81,11 @@ class AFCReport(Command):
user_name = user.name user_name = user.name
user_url = user.get_talkpage().url user_url = user.get_talkpage().url


msg1 = "AfC submission report for \x0302{0}\x0301 ({1}):"
msg2 = "Status: \x0303{0}\x0301"
msg3 = "Submitted by \x0302{0}\x0301 ({1})"
msg1 = "AfC submission report for \x0302{0}\x0F ({1}):"
msg2 = "Status: \x0303{0}\x0F"
msg3 = "Submitted by \x0302{0}\x0F ({1})"
if status == "accepted": if status == "accepted":
msg3 = "Reviewed by \x0302{0}\x0301 ({1})"
msg3 = "Reviewed by \x0302{0}\x0F ({1})"


self.reply(self.data, msg1.format(short, url)) self.reply(self.data, msg1.format(short, url))
self.say(self.data.chan, msg2.format(status)) self.say(self.data.chan, msg2.format(status))


+ 14
- 14
earwigbot/commands/afc_status.py View File

@@ -54,17 +54,17 @@ class AFCStatus(Command):
action = data.args[0].lower() action = data.args[0].lower()
if action.startswith("sub") or action == "s": if action.startswith("sub") or action == "s":
subs = self.count_submissions() subs = self.count_submissions()
msg = "there are \x0305{0}\x0301 pending AfC submissions (\x0302WP:AFC\x0301)."
msg = "there are \x0305{0}\x0F pending AfC submissions (\x0302WP:AFC\x0F)."
self.reply(data, msg.format(subs)) self.reply(data, msg.format(subs))


elif action.startswith("redir") or action == "r": elif action.startswith("redir") or action == "r":
redirs = self.count_redirects() redirs = self.count_redirects()
msg = "there are \x0305{0}\x0301 open redirect requests (\x0302WP:AFC/R\x0301)."
msg = "there are \x0305{0}\x0F open redirect requests (\x0302WP:AFC/R\x0F)."
self.reply(data, msg.format(redirs)) self.reply(data, msg.format(redirs))


elif action.startswith("file") or action == "f": elif action.startswith("file") or action == "f":
files = self.count_redirects() files = self.count_redirects()
msg = "there are \x0305{0}\x0301 open file upload requests (\x0302WP:FFU\x0301)."
msg = "there are \x0305{0}\x0F open file upload requests (\x0302WP:FFU\x0F)."
self.reply(data, msg.format(files)) self.reply(data, msg.format(files))


elif action.startswith("agg") or action == "a": elif action.startswith("agg") or action == "a":
@@ -75,18 +75,18 @@ class AFCStatus(Command):
self.count_redirects(), self.count_files()) self.count_redirects(), self.count_files())
agg_num = self.get_aggregate_number(agg_data) agg_num = self.get_aggregate_number(agg_data)
except ValueError: except ValueError:
msg = "\x0303{0}\x0301 isn't a number!"
msg = "\x0303{0}\x0F isn't a number!"
self.reply(data, msg.format(data.args[1])) self.reply(data, msg.format(data.args[1]))
return return
aggregate = self.get_aggregate(agg_num) aggregate = self.get_aggregate(agg_num)
msg = "aggregate is \x0305{0}\x0301 (AfC {1})."
msg = "aggregate is \x0305{0}\x0F (AfC {1})."
self.reply(data, msg.format(agg_num, aggregate)) self.reply(data, msg.format(agg_num, aggregate))


elif action.startswith("nocolor") or action == "n": elif action.startswith("nocolor") or action == "n":
self.reply(data, self.get_status(color=False)) self.reply(data, self.get_status(color=False))


else: else:
msg = "unknown argument: \x0303{0}\x0301. Valid args are 'subs', 'redirs', 'files', 'agg', 'nocolor'."
msg = "unknown argument: \x0303{0}\x0F. Valid args are 'subs', 'redirs', 'files', 'agg', 'nocolor'."
self.reply(data, msg.format(data.args[0])) self.reply(data, msg.format(data.args[0]))


else: else:
@@ -100,7 +100,7 @@ class AFCStatus(Command):
aggregate = self.get_aggregate(agg_num) aggregate = self.get_aggregate(agg_num)


if color: if color:
msg = "Articles for creation {0} (\x0302AFC\x0301: \x0305{1}\x0301; \x0302AFC/R\x0301: \x0305{2}\x0301; \x0302FFU\x0301: \x0305{3}\x0301)."
msg = "Articles for creation {0} (\x0302AFC\x0F: \x0305{1}\x0F; \x0302AFC/R\x0F: \x0305{2}\x0F; \x0302FFU\x0F: \x0305{3}\x0F)."
else: else:
msg = "Articles for creation {0} (AFC: {1}; AFC/R: {2}; FFU: {3})." msg = "Articles for creation {0} (AFC: {1}; AFC/R: {2}; FFU: {3})."
return msg.format(aggregate, subs, redirs, files) return msg.format(aggregate, subs, redirs, files)
@@ -140,19 +140,19 @@ class AFCStatus(Command):
FFU (for example) indicates that our work is *not* done and the FFU (for example) indicates that our work is *not* done and the
project-wide backlog is most certainly *not* clear.""" project-wide backlog is most certainly *not* clear."""
if num == 0: if num == 0:
return "is \x02\x0303clear\x0301\x0F"
return "is \x02\x0303clear\x0F"
elif num <= 200: elif num <= 200:
return "is \x0303almost clear\x0301"
return "is \x0303almost clear\x0F"
elif num <= 400: elif num <= 400:
return "is \x0312normal\x0301"
return "is \x0312normal\x0F"
elif num <= 600: elif num <= 600:
return "is \x0307lightly backlogged\x0301"
return "is \x0307lightly backlogged\x0F"
elif num <= 900: elif num <= 900:
return "is \x0304backlogged\x0301"
return "is \x0304backlogged\x0F"
elif num <= 1200: elif num <= 1200:
return "is \x02\x0304heavily backlogged\x0301\x0F"
return "is \x02\x0304heavily backlogged\x0F"
else: else:
return "is \x02\x1F\x0304severely backlogged\x0301\x0F"
return "is \x02\x1F\x0304severely backlogged\x0F"


def get_aggregate_number(self, (subs, redirs, files)): def get_aggregate_number(self, (subs, redirs, files)):
"""Returns an 'aggregate number' based on the real number of pending """Returns an 'aggregate number' based on the real number of pending


+ 2
- 2
earwigbot/commands/geolocate.py View File

@@ -45,7 +45,7 @@ class Geolocate(Command):
return return


if not self.key: if not self.key:
msg = 'I need an API key for http://ipinfodb.com/ stored as \x0303config.commands["{0}"]["apiKey"]\x0301.'
msg = 'I need an API key for http://ipinfodb.com/ stored as \x0303config.commands["{0}"]["apiKey"]\x0F.'
log = 'Need an API key for http://ipinfodb.com/ stored as config.commands["{0}"]["apiKey"]' log = 'Need an API key for http://ipinfodb.com/ stored as config.commands["{0}"]["apiKey"]'
self.reply(data, msg.format(self.name) + ".") self.reply(data, msg.format(self.name) + ".")
self.logger.error(log.format(self.name)) self.logger.error(log.format(self.name))
@@ -64,7 +64,7 @@ class Geolocate(Command):
longitude = res["longitude"] longitude = res["longitude"]
utcoffset = res["timeZone"] utcoffset = res["timeZone"]
except KeyError: except KeyError:
self.reply(data, "IP \x0302{0}\x0301 not found.".format(address))
self.reply(data, "IP \x0302{0}\x0F not found.".format(address))
return return


msg = "{0}, {1}, {2} ({3}, {4}), UTC {5}" msg = "{0}, {1}, {2} ({3}, {4}), UTC {5}"


+ 15
- 15
earwigbot/commands/git.py View File

@@ -78,12 +78,12 @@ class Git(Command):
elif command == "status": elif command == "status":
self.do_status() self.do_status()
else: # They asked us to do something we don't know else: # They asked us to do something we don't know
msg = "unknown argument: \x0303{0}\x0301.".format(data.args[0])
msg = "unknown argument: \x0303{0}\x0F.".format(data.args[0])
self.reply(data, msg) self.reply(data, msg)


def get_repos(self): def get_repos(self):
data = self.repos.iteritems() data = self.repos.iteritems()
repos = ["\x0302{0}\x0301 ({1})".format(k, v) for k, v in data]
repos = ["\x0302{0}\x0F ({1})".format(k, v) for k, v in data]
return ", ".join(repos) return ", ".join(repos)


def get_remote(self): def get_remote(self):
@@ -94,7 +94,7 @@ class Git(Command):
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}\x0F.".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):
@@ -119,21 +119,21 @@ class Git(Command):
} }
subcommands = "" subcommands = ""
for key in sorted(help.keys()): for key in sorted(help.keys()):
subcommands += "\x0303{0}\x0301 ({1}), ".format(key, help[key])
subcommands += "\x0303{0}\x0F ({1}), ".format(key, help[key])
subcommands = subcommands[:-2] # Trim last comma and space subcommands = subcommands[:-2] # Trim last comma and space
msg = "sub-commands are: {0}; repos are: {1}. Syntax: !git \x0303subcommand\x0301 \x0302repo\x0301."
msg = "sub-commands are: {0}; repos are: {1}. Syntax: !git \x0303subcommand\x0F \x0302repo\x0F."
self.reply(self.data, msg.format(subcommands, self.get_repos())) self.reply(self.data, msg.format(subcommands, self.get_repos()))


def do_branch(self): def do_branch(self):
"""Get our current branch.""" """Get our current branch."""
branch = self.repo.active_branch.name branch = self.repo.active_branch.name
msg = "currently on branch \x0302{0}\x0301.".format(branch)
msg = "currently on branch \x0302{0}\x0F.".format(branch)
self.reply(self.data, msg) self.reply(self.data, msg)


def do_branches(self): def do_branches(self):
"""Get a list of branches.""" """Get a list of branches."""
branches = [branch.name for branch in self.repo.branches] branches = [branch.name for branch in self.repo.branches]
msg = "branches: \x0302{0}\x0301.".format(", ".join(branches))
msg = "branches: \x0302{0}\x0F.".format(", ".join(branches))
self.reply(self.data, msg) self.reply(self.data, msg)


def do_checkout(self): def do_checkout(self):
@@ -146,18 +146,18 @@ class Git(Command):


current_branch = self.repo.active_branch.name current_branch = self.repo.active_branch.name
if target == current_branch: if target == current_branch:
msg = "already on \x0302{0}\x0301!".format(target)
msg = "already on \x0302{0}\x0F!".format(target)
self.reply(self.data, msg) self.reply(self.data, msg)
return return


try: try:
ref = getattr(self.repo.branches, target) ref = getattr(self.repo.branches, target)
except AttributeError: except AttributeError:
msg = "branch \x0302{0}\x0301 doesn't exist!".format(target)
msg = "branch \x0302{0}\x0F doesn't exist!".format(target)
self.reply(self.data, msg) self.reply(self.data, msg)
else: else:
ref.checkout() ref.checkout()
ms = "switched from branch \x0302{0}\x0301 to \x0302{1}\x0301."
ms = "switched from branch \x0302{0}\x0F to \x0302{1}\x0F."
msg = ms.format(current_branch, target) msg = ms.format(current_branch, target)
self.reply(self.data, msg) self.reply(self.data, msg)
log = "{0} checked out branch {1} of {2}" log = "{0} checked out branch {1} of {2}"
@@ -181,11 +181,11 @@ class Git(Command):
try: try:
ref = getattr(self.repo.branches, target) ref = getattr(self.repo.branches, target)
except AttributeError: except AttributeError:
msg = "branch \x0302{0}\x0301 doesn't exist!".format(target)
msg = "branch \x0302{0}\x0F doesn't exist!".format(target)
self.reply(self.data, msg) self.reply(self.data, msg)
else: else:
self.repo.git.branch("-d", ref) self.repo.git.branch("-d", ref)
msg = "branch \x0302{0}\x0301 has been deleted locally."
msg = "branch \x0302{0}\x0F has been deleted locally."
self.reply(self.data, msg.format(target)) self.reply(self.data, msg.format(target))
log = "{0} deleted branch {1} of {2}" log = "{0} deleted branch {1} of {2}"
logmsg = log.format(self.data.nick, target, self.repo.working_dir) logmsg = log.format(self.data.nick, target, self.repo.working_dir)
@@ -194,7 +194,7 @@ class Git(Command):
def do_pull(self): def do_pull(self):
"""Pull from our remote repository.""" """Pull from our remote repository."""
branch = self.repo.active_branch.name branch = self.repo.active_branch.name
msg = "pulling from remote (currently on \x0302{0}\x0301)..."
msg = "pulling from remote (currently on \x0302{0}\x0F)..."
self.reply(self.data, msg.format(branch)) self.reply(self.data, msg.format(branch))


remote = self.get_remote() remote = self.get_remote()
@@ -205,7 +205,7 @@ class Git(Command):


if updated: if updated:
branches = ", ".join([info.ref.remote_head for info in updated]) branches = ", ".join([info.ref.remote_head for info in updated])
msg = "done; updates to \x0302{0}\x0301 (from {1})."
msg = "done; updates to \x0302{0}\x0F (from {1})."
self.reply(self.data, msg.format(branches, remote.url)) self.reply(self.data, msg.format(branches, remote.url))
log = "{0} pulled {1} of {2} (updates to {3})" log = "{0} pulled {1} of {2} (updates to {3})"
self.logger.info(log.format(self.data.nick, remote.name, self.logger.info(log.format(self.data.nick, remote.name,
@@ -227,7 +227,7 @@ class Git(Command):


if updated: if updated:
branches = ", ".join([info.ref.remote_head for info in updated]) branches = ", ".join([info.ref.remote_head for info in updated])
msg = "last local commit was \x02{0}\x0F ago; updates to \x0302{1}\x0301."
msg = "last local commit was \x02{0}\x0F ago; updates to \x0302{1}\x0F."
self.reply(self.data, msg.format(since, branches)) self.reply(self.data, msg.format(since, branches))
log = "{0} got status of {1} of {2} (updates to {3})" log = "{0} got status of {1} of {2} (updates to {3})"
self.logger.info(log.format(self.data.nick, remote.name, self.logger.info(log.format(self.data.nick, remote.name,


+ 2
- 2
earwigbot/commands/help.py View File

@@ -60,11 +60,11 @@ class Help(Command):
if command.__doc__: if command.__doc__:
doc = command.__doc__.replace("\n", "") doc = command.__doc__.replace("\n", "")
doc = re.sub("\s\s+", " ", doc) doc = re.sub("\s\s+", " ", doc)
msg = 'help for command \x0303{0}\x0301: "{1}"'
msg = 'help for command \x0303{0}\x0F: "{1}"'
self.reply(data, msg.format(target, doc)) self.reply(data, msg.format(target, doc))
return return


msg = "sorry, no help for \x0303{0}\x0301.".format(target)
msg = "sorry, no help for \x0303{0}\x0F.".format(target)
self.reply(data, msg) self.reply(data, msg)


def do_hello(self, data): def do_hello(self, data):


+ 2
- 2
earwigbot/commands/langcode.py View File

@@ -46,8 +46,8 @@ class Langcode(Command):
if name != localname: if name != localname:
name += " ({0})".format(localname) name += " ({0})".format(localname)
sites = ", ".join([s["url"] for s in site["site"]]) sites = ", ".join([s["url"] for s in site["site"]])
msg = "\x0302{0}\x0301 is {1} ({2})".format(code, name, sites)
msg = "\x0302{0}\x0F is {1} ({2})".format(code, name, sites)
self.reply(data, msg) self.reply(data, msg)
return return


self.reply(data, "language \x0302{0}\x0301 not found.".format(code))
self.reply(data, "language \x0302{0}\x0F not found.".format(code))

+ 2
- 2
earwigbot/commands/registration.py View File

@@ -42,7 +42,7 @@ class Registration(Command):
try: try:
reg = user.registration reg = user.registration
except exceptions.UserNotFoundError: except exceptions.UserNotFoundError:
msg = "the user \x0302{0}\x0301 does not exist."
msg = "the user \x0302{0}\x0F does not exist."
self.reply(data, msg.format(name)) self.reply(data, msg.format(name))
return return


@@ -56,7 +56,7 @@ class Registration(Command):
else: else:
gender = "They're" # Singluar they? gender = "They're" # Singluar they?


msg = "\x0302{0}\x0301 registered on {1}. {2} {3} old."
msg = "\x0302{0}\x0F registered on {1}. {2} {3} old."
self.reply(data, msg.format(name, date, gender, age)) self.reply(data, msg.format(name, date, gender, age))


def get_diff(self, t1, t2): def get_diff(self, t1, t2):


+ 1
- 1
earwigbot/commands/replag.py View File

@@ -53,5 +53,5 @@ class Replag(Command):
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}\x0F is \x02{1}\x0F seconds."
self.reply(data, msg.format(args["db"], replag)) self.reply(data, msg.format(args["db"], replag))

+ 2
- 2
earwigbot/commands/rights.py View File

@@ -40,7 +40,7 @@ class Rights(Command):
try: try:
rights = user.groups rights = user.groups
except exceptions.UserNotFoundError: except exceptions.UserNotFoundError:
msg = "the user \x0302{0}\x0301 does not exist."
msg = "the user \x0302{0}\x0F does not exist."
self.reply(data, msg.format(name)) self.reply(data, msg.format(name))
return return


@@ -48,5 +48,5 @@ class Rights(Command):
rights.remove("*") # Remove the '*' group given to everyone rights.remove("*") # Remove the '*' group given to everyone
except ValueError: except ValueError:
pass pass
msg = "the rights for \x0302{0}\x0301 are {1}."
msg = "the rights for \x0302{0}\x0F are {1}."
self.reply(data, msg.format(name, ', '.join(rights))) self.reply(data, msg.format(name, ', '.join(rights)))

+ 9
- 9
earwigbot/commands/threads.py View File

@@ -55,7 +55,7 @@ class Threads(Command):
self.do_listall() self.do_listall()


else: # They asked us to do something we don't know else: # They asked us to do something we don't know
msg = "unknown argument: \x0303{0}\x0301.".format(data.args[0])
msg = "unknown argument: \x0303{0}\x0F.".format(data.args[0])
self.reply(data, msg) self.reply(data, msg)


def do_list(self): def do_list(self):
@@ -70,18 +70,18 @@ class Threads(Command):
for thread in threads: for thread in threads:
tname = thread.name tname = thread.name
if tname == "MainThread": if tname == "MainThread":
t = "\x0302MainThread\x0301 (id {0})"
t = "\x0302MainThread\x0F (id {0})"
normal_threads.append(t.format(thread.ident)) normal_threads.append(t.format(thread.ident))
elif tname in self.config.components: elif tname in self.config.components:
t = "\x0302{0}\x0301 (id {1})"
t = "\x0302{0}\x0F (id {1})"
normal_threads.append(t.format(tname, thread.ident)) normal_threads.append(t.format(tname, thread.ident))
elif tname.startswith("reminder"): elif tname.startswith("reminder"):
tname = tname.replace("reminder ", "") tname = tname.replace("reminder ", "")
t = "\x0302reminder\x0301 (until {0})"
t = "\x0302reminder\x0F (until {0})"
normal_threads.append(t.format(tname)) normal_threads.append(t.format(tname))
else: else:
tname, start_time = re.findall("^(.*?) \((.*?)\)$", tname)[0] tname, start_time = re.findall("^(.*?) \((.*?)\)$", tname)[0]
t = "\x0302{0}\x0301 (id {1}, since {2})"
t = "\x0302{0}\x0F (id {1}, since {2})"
daemon_threads.append(t.format(tname, thread.ident, daemon_threads.append(t.format(tname, thread.ident,
start_time)) start_time))


@@ -107,12 +107,12 @@ class Threads(Command):
threadlist = [t for t in threads if t.name.startswith(task)] threadlist = [t for t in threads if t.name.startswith(task)]
ids = [str(t.ident) for t in threadlist] ids = [str(t.ident) for t in threadlist]
if not ids: if not ids:
tasklist.append("\x0302{0}\x0301 (idle)".format(task))
tasklist.append("\x0302{0}\x0F (idle)".format(task))
elif len(ids) == 1: elif len(ids) == 1:
t = "\x0302{0}\x0301 (\x02active\x0F as id {1})"
t = "\x0302{0}\x0F (\x02active\x0F as id {1})"
tasklist.append(t.format(task, ids[0])) tasklist.append(t.format(task, ids[0]))
else: else:
t = "\x0302{0}\x0301 (\x02active\x0F as ids {1})"
t = "\x0302{0}\x0F (\x02active\x0F as ids {1})"
tasklist.append(t.format(task, ', '.join(ids))) tasklist.append(t.format(task, ', '.join(ids)))


tasks = ", ".join(tasklist) tasks = ", ".join(tasklist)
@@ -139,5 +139,5 @@ class Threads(Command):


data.kwargs["fromIRC"] = True data.kwargs["fromIRC"] = True
self.bot.tasks.start(task_name, **data.kwargs) self.bot.tasks.start(task_name, **data.kwargs)
msg = "task \x0302{0}\x0301 started.".format(task_name)
msg = "task \x0302{0}\x0F started.".format(task_name)
self.reply(data, msg) self.reply(data, msg)

+ 1
- 1
earwigbot/irc/connection.py View File

@@ -142,7 +142,7 @@ class IRCConnection(object):


def reply(self, data, msg, hidelog=False): def reply(self, data, msg, hidelog=False):
"""Send a private message as a reply to a user on the server.""" """Send a private message as a reply to a user on the server."""
msg = "\x02{0}\x0f: {1}".format(data.nick, msg)
msg = "\x02{0}\x0F: {1}".format(data.nick, msg)
self.say(data.chan, msg, hidelog) self.say(data.chan, msg, hidelog)


def action(self, target, msg, hidelog=False): def action(self, target, msg, hidelog=False):


Loading…
Cancel
Save