A Python robot that edits Wikipedia and interacts with people over IRC https://en.wikipedia.org/wiki/User:EarwigBot
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

1234567891011121314151617181920212223242526272829303132333435
  1. # -*- coding: utf-8 -*-
  2. # A class to store data from an individual line received on IRC.
  3. class Data(object):
  4. def __init__(self):
  5. """store data from an individual line received on IRC"""
  6. self.line = str()
  7. self.chan = str()
  8. self.nick = str()
  9. self.ident = str()
  10. self.host = str()
  11. self.msg = str()
  12. def parse_args(self):
  13. """parse command arguments from self.msg into self.command and self.args"""
  14. args = self.msg.strip().split(' ') # strip out extra whitespace and split the message into a list
  15. while '' in args: # remove any empty arguments
  16. args.remove('')
  17. self.args = args[1:] # the command arguments
  18. self.is_command = False # whether this is a real command or not
  19. try:
  20. self.command = args[0] # the command itself
  21. except IndexError:
  22. self.command = None
  23. try:
  24. if self.command.startswith('!') or self.command.startswith('.'):
  25. self.is_command = True
  26. self.command = self.command[1:] # strip '!' or '.'
  27. self.command = self.command.lower() # lowercase command name
  28. except AttributeError:
  29. pass