A Python robot that edits Wikipedia and interacts with people over IRC https://en.wikipedia.org/wiki/User:EarwigBot
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

watcher.py 1.2 KiB

123456789101112131415161718192021222324252627282930313233
  1. # -*- coding: utf-8 -*-
  2. # EarwigBot Configuration File
  3. # This file contains rules for the bot's watcher component.
  4. import re
  5. AFC_CHANS = ["#wikipedia-en-afc"] # report recent AfC changes/give AfC status messages upon join
  6. BOT_CHANS = ["##earwigbot", "#wikipedia-en-afc"] # report edits containing "!earwigbot"
  7. def process(rc):
  8. chans = set() # channels to report this message to
  9. page_name = rc.page.lower()
  10. if "!earwigbot" in rc.msg.lower():
  11. chans.update(BOT_CHANS)
  12. if re.match("wikipedia( talk)?:(wikiproject )?articles for creation", page_name):
  13. chans.update(AFC_CHANS)
  14. elif re.match("wikipedia( talk)?:files for upload", page_name):
  15. chans.update(AFC_CHANS)
  16. elif page_name.startswith("template:afc submission"):
  17. chans.update(AFC_CHANS)
  18. elif rc.flags == "delete" and re.match("deleted \"\[\[wikipedia( talk)?:(wikiproject )?articles for creation", rc.comment.lower()):
  19. chans.update(AFC_CHANS)
  20. elif rc.flags == "protect" and re.match("protected \"\[\[wikipedia( talk)?:(wikiproject )?articles for creation", rc.comment.lower()):
  21. chans.update(AFC_CHANS)
  22. return chans