A Python robot that edits Wikipedia and interacts with people over IRC https://en.wikipedia.org/wiki/User:EarwigBot
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
123456789101112131415161718192021222324252627282930313233
  1. # -*- coding: utf-8 -*-
  2. # A base class for commands on IRC.
  3. class BaseCommand(object):
  4. def __init__(self, connection):
  5. """A base class for commands on IRC."""
  6. self.connection = connection
  7. def get_hooks(self):
  8. """Hooks are: 'msg', 'msg_private', 'msg_public', and 'join'. Return
  9. the hooks you want this command to be called on."""
  10. return []
  11. def get_help(self, command):
  12. """Return help information for the command, used by !help. return None
  13. for no help. If a given class handles multiple commands, the command
  14. variable can be used to return different help for each one."""
  15. return None
  16. def check(self, data):
  17. """Given a Data() object, return True if we should respond to this
  18. activity, or False if we should ignore it/it doesn't apply to us. Most
  19. commands return True if data.command == 'command_name', otherwise
  20. they return False."""
  21. return False
  22. def process(self, data):
  23. """Handle an activity (usually a message) on IRC. At this point, thanks
  24. to self.check() which is called automatically by command_handler, we
  25. know this is something we should respond to, so (usually) a
  26. 'if data.command != "command_name": return' is unnecessary."""
  27. pass