A Python robot that edits Wikipedia and interacts with people over IRC https://en.wikipedia.org/wiki/User:EarwigBot
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

chanops.py 1.1 KiB

1234567891011121314151617181920212223242526272829303132333435
  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)