A Python robot that edits Wikipedia and interacts with people over IRC https://en.wikipedia.org/wiki/User:EarwigBot
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

data.py 806 B

12345678910111213141516171819202122232425
  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. self.args = args[1:] # the command arguments