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.

afc_statistics.py 1.5 KiB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. # -*- coding: utf-8 -*-
  2. from os import path
  3. from classes import BaseTask
  4. import config
  5. class Task(BaseTask):
  6. """A task to generate statistics for WikiProject Articles for Creation.
  7. Statistics are stored in the file indicated by self.filename,
  8. "statistics.txt" in the bot's root directory being the default. They are
  9. updated live while watching the recent changes IRC feed.
  10. The bot saves its statistics once an hour, on the hour, to self.pagename.
  11. In the live bot, this is "Template:AFC statistics".
  12. """
  13. name = "afc_statistics"
  14. def __init__(self):
  15. self.filename = path.join(config.root_dir, "statistics.txt")
  16. self.pagename = "User:EarwigBot/Sandbox/Statistics"
  17. def run(self, **kwargs):
  18. try:
  19. action = kwargs["action"]
  20. except KeyError:
  21. return
  22. if action == "save":
  23. self.save()
  24. else:
  25. try:
  26. page = kwargs["page"]
  27. except KeyError:
  28. return
  29. if action == "edit":
  30. self.process_edit(page)
  31. elif action == "move":
  32. self.process_move(page)
  33. elif action == "delete":
  34. self.process_delete(page)
  35. elif action == "restore":
  36. self.process_restore(page)
  37. def save(self):
  38. pass
  39. def process_edit(self, page):
  40. pass
  41. def process_move(self, page):
  42. pass
  43. def process_delete(self, page):
  44. pass
  45. def process_restore(self, page):
  46. pass