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.

help.py 924 B

12345678910111213141516171819202122232425262728293031323334
  1. # -*- coding: utf-8 -*-
  2. """Generates help information."""
  3. connection, data = None, None
  4. def call(c, d):
  5. global connection, data
  6. connection, data = c, d
  7. if not data.args:
  8. do_general_help()
  9. else:
  10. do_command_help()
  11. def do_general_help():
  12. connection.reply(data.chan, data.nick, "I am a bot! You can get help for any command by typing '!help <command>'.")
  13. def do_command_help():
  14. command = data.args[0]
  15. try:
  16. exec "from irc.commands import %s as this_command" % command
  17. except ImportError:
  18. connection.reply(data.chan, data.nick, "command \x0303%s\x0301 not found!" % command)
  19. return
  20. info = this_command.__doc__
  21. if info:
  22. connection.reply(data.chan, data.nick, "info for command \x0303%s\x0301: \"%s\"" % (command, info))
  23. else:
  24. connection.reply(data.chan, data.nick, "sorry, no information for \x0303%s\x0301." % command)