A Python robot that edits Wikipedia and interacts with people over IRC https://en.wikipedia.org/wiki/User:EarwigBot

36 рядки
1.1 KiB

  1. # -*- coding: utf-8 -*-
  2. from classes import BaseCommand
  3. import config
  4. class Command(BaseCommand):
  5. """Voice, devoice, op, or deop users in the channel."""
  6. name = "chanops"
  7. def check(self, data):
  8. commands = ["chanops", "voice", "devoice", "op", "deop"]
  9. if data.is_command and data.command in commands:
  10. return True
  11. return False
  12. def process(self, data):
  13. if data.command == "chanops":
  14. msg = "available commands are !voice, !devoice, !op, and !deop."
  15. self.connection.reply(data, msg)
  16. return
  17. if data.host not in config.irc["permissions"]["admins"]:
  18. msg = "you must be a bot admin to use this command."
  19. self.connection.reply(data, msg)
  20. return
  21. # If it is just !op/!devoice/whatever without arguments, assume they
  22. # want to do this to themselves:
  23. if not data.args:
  24. target = data.nick
  25. else:
  26. target = data.args[0]
  27. msg = " ".join((data.command, data.chan, target))
  28. self.connection.say("ChanServ", msg)