A Python robot that edits Wikipedia and interacts with people over IRC https://en.wikipedia.org/wiki/User:EarwigBot
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

triggers.py 1.2 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # -*- coding: utf-8 -*-
  2. # Check what events on IRC we can respond to.
  3. from irc.commands import test, help, git, link, chanops
  4. def get_alias(key):
  5. """used by help.py, e.g. so we know !voice corresponds to chanops.py"""
  6. aliases = {
  7. "voice": chanops,
  8. "devoice": chanops,
  9. "op": chanops,
  10. "deop": chanops,
  11. }
  12. return aliases[key]
  13. def check(connection, data, hook):
  14. data.parse_args() # parse command arguments into data.command and data.args
  15. if hook == "join":
  16. pass
  17. if hook == "msg_private":
  18. pass
  19. if hook == "msg_public":
  20. pass
  21. if hook == "msg":
  22. if data.command == "!test":
  23. test.call(connection, data)
  24. elif data.command == "!help":
  25. help.call(connection, data)
  26. elif data.command == "!git":
  27. git.call(connection, data)
  28. elif (data.command == "!link" or
  29. ("[[" in data.msg and "]]" in data.msg) or
  30. ("{{" in data.msg and "}}" in data.msg)):
  31. link.call(connection, data)
  32. elif (data.command == "!voice" or data.command == "!devoice" or
  33. data.command == "!op" or data.command == "!deop"):
  34. chanops.call(connection, data)