A Python robot that edits Wikipedia and interacts with people over IRC https://en.wikipedia.org/wiki/User:EarwigBot
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

12345678910111213141516171819202122232425262728
  1. # -*- coding: utf-8 -*-
  2. # A class to store data from an individual line received on IRC.
  3. class Data:
  4. def __init__(self):
  5. """store data from an individual line received on IRC"""
  6. self.chan = str()
  7. self.nick = str()
  8. self.ident = str()
  9. self.host = str()
  10. self.msg = str()
  11. def parse_args(self):
  12. """parse command arguments from self.msg into self.command and self.args"""
  13. args = self.msg.strip().split(' ') # strip out extra whitespace and split the message into a list
  14. while '' in args: # remove any empty arguments
  15. args.remove('')
  16. try:
  17. self.command = args[0] # the command itself
  18. except IndexError:
  19. self.command = None
  20. try:
  21. self.args = args[1:] # the command arguments
  22. except IndexError:
  23. self.args = None