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.

42 lines
2.1 KiB

  1. Tips
  2. ====
  3. - Logging_ is a fantastic way to monitor the bot's progress as it runs. It has
  4. a slew of built-in loggers, and enabling log retention (so logs are saved to
  5. ``logs/`` in the working directory) is highly recommended. In the normal
  6. setup, there are three log files, each of which "rotate" at a specific time
  7. (``filename.log`` becomes ``filename.log.2012-04-10``, for example). The
  8. ``debug.log`` file rotates every hour, and maintains six hours of logs of
  9. every level (``DEBUG`` and up). ``bot.log`` rotates every day at midnight,
  10. and maintains seven days of non-debug logs (``INFO`` and up). Finally,
  11. ``error.log`` rotates every Sunday night, and maintains four weeks of logs
  12. indicating unexpected events (``WARNING`` and up).
  13. To use logging in your commands or tasks (recommended), ``BaseCommand`` and
  14. ``BaseTask`` provide ``logger`` attributes configured for the specific
  15. command or task. If you're working with other classes, ``bot.logger`` is the
  16. root logger (``logging.getLogger("earwigbot")`` by default), so you can use
  17. ``getChild`` to make your logger. For example, task loggers are essentially
  18. ``bot.logger.getChild("tasks").getChild(task.name)``.
  19. - A very useful IRC command is "``!reload``", which reloads all commands and
  20. tasks without restarting the bot. [1]_ Combined with using the `!git plugin`_
  21. for pulling repositories from IRC, this can provide a seamless command/task
  22. development workflow if the bot runs on an external server and you set up
  23. its working directory as a git repo.
  24. - You can run a task by itself instead of the entire bot with ``earwigbot
  25. path/to/working/dir --task task_name``.
  26. - Questions, comments, or suggestions about the documentation? `Let me know`_
  27. so I can improve it for other people.
  28. .. rubric:: Footnotes
  29. .. [1] In reality, all this does is call ``bot.commands.load()`` and
  30. ``bot.tasks.load()``!
  31. .. _logging: http://docs.python.org/library/logging.html
  32. .. _Let me know: ben.kurtovic@verizon.net
  33. .. _!git plugin: https://github.com/earwig/earwigbot-plugins/blob/develop/commands/git.py