Browse Source

Improve parsing rules for usernames in signatures.

tags/v0.1^2
Ben Kurtovic 12 years ago
parent
commit
db59f2ba48
1 changed files with 4 additions and 3 deletions
  1. +4
    -3
      earwigbot/tasks/drn_clerkbot.py

+ 4
- 3
earwigbot/tasks/drn_clerkbot.py View File

@@ -141,7 +141,7 @@ class DRNClerkBot(Task):
for line in text.splitlines(): for line in text.splitlines():
user = re.search("\# \{\{User\|(.*?)\}\}", line) user = re.search("\# \{\{User\|(.*?)\}\}", line)
if user: if user:
additions.add((user.group(1),))
additions.add((user.group(1).replace("_", " ").strip(),))


removals = set() removals = set()
query1 = "SELECT volunteer_username FROM volunteers" query1 = "SELECT volunteer_username FROM volunteers"
@@ -355,7 +355,8 @@ class DRNClerkBot(Task):
matches = re.findall(regex, text, re.U) matches = re.findall(regex, text, re.U)
signatures = [] signatures = []
for userlink, stamp in matches: for userlink, stamp in matches:
username = userlink.split("/", 1)[0].replace("_", " ")
username = userlink.split("/", 1)[0].replace("_", " ").strip()
stamp = stamp.strip()
timestamp = datetime.strptime(stamp, "%H:%M, %d %B %Y (UTC)") timestamp = datetime.strptime(stamp, "%H:%M, %d %B %Y (UTC)")
signatures.append((username, timestamp)) signatures.append((username, timestamp))
return signatures return signatures
@@ -380,7 +381,7 @@ class DRNClerkBot(Task):
for line in text.group(1).splitlines(): for line in text.group(1).splitlines():
user = re.search("[:*#]{,5} \{\{User\|(.*?)\}\}", line) user = re.search("[:*#]{,5} \{\{User\|(.*?)\}\}", line)
if user: if user:
party = user.group(1).strip()
party = user.group(1).replace("_", " ").strip()
notice = _Notice("User talk:" + party, template, too_late) notice = _Notice("User talk:" + party, template, too_late)
notices.append(notice) notices.append(notice)




Loading…
Cancel
Save