A Python robot that edits Wikipedia and interacts with people over IRC https://en.wikipedia.org/wiki/User:EarwigBot
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

watcher.py 1.4 KiB

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