A Python robot that edits Wikipedia and interacts with people over IRC https://en.wikipedia.org/wiki/User:EarwigBot
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

12 年前
12 年前
12 年前
12 年前
12 年前
12 年前
123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. :file:`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. (:file:`filename.log` becomes :file:`filename.log.2012-04-10`, for example).
  8. The :file:`debug.log` file rotates every hour, and maintains six hours of
  9. logs of every level (``DEBUG`` and up). :file:`bot.log` rotates every day at
  10. midnight, and maintains seven days of non-debug logs (``INFO`` and up).
  11. Finally, :file:`error.log` rotates every Sunday night, and maintains four
  12. weeks of logs indicating unexpected events (``WARNING`` and up).
  13. To use logging in your commands or tasks (recommended),
  14. :py:class:~earwigbot.commands.BaseCommand` and
  15. :py:class:~earwigbot.tasks.BaseTask` provide :py:attr:`logger` attributes
  16. configured for the specific command or task. If you're working with other
  17. classes, :py:attr:`bot.logger` is the root logger
  18. (:py:obj:`logging.getLogger("earwigbot")` by default), so you can use
  19. :py:func:`~logging.Logger.getChild` to make your logger. For example, task
  20. loggers are essentially
  21. :py:attr:`bot.logger.getChild("tasks").getChild(task.name) <bot.logger>`.
  22. - A very useful IRC command is "``!reload``", which reloads all commands and
  23. tasks without restarting the bot. [1]_ Combined with using the `!git plugin`_
  24. for pulling repositories from IRC, this can provide a seamless command/task
  25. development workflow if the bot runs on an external server and you set up
  26. its working directory as a git repo.
  27. - You can run a task by itself instead of the entire bot with
  28. :command:`earwigbot path/to/working/dir --task task_name`.
  29. - Questions, comments, or suggestions about the documentation?
  30. `Create an issue`_ so I can improve it for other people.
  31. .. rubric:: Footnotes
  32. .. [1] In reality, all this does is call :py:meth:`bot.commands.load()
  33. <earwigbot.managers._ResourceManager.load>` and
  34. :py:meth:`bot.tasks.load() <earwigbot.managers._ResourceManager.load>`!
  35. .. _logging: https://docs.python.org/library/logging.html
  36. .. _!git plugin: https://github.com/earwig/earwigbot-plugins/blob/develop/commands/git.py
  37. .. _create an issue: https://github.com/earwig/earwigbot/issues