diff options
Diffstat (limited to 'wmd/parser.py')
| -rw-r--r-- | wmd/parser.py | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/wmd/parser.py b/wmd/parser.py index 99173be..cf88f75 100644 --- a/wmd/parser.py +++ b/wmd/parser.py | |||
| @@ -11,6 +11,13 @@ class ircparse(object): | |||
| 11 | if data != '': | 11 | if data != '': |
| 12 | self._process_data(data) | 12 | self._process_data(data) |
| 13 | 13 | ||
| 14 | def getUsername(self): | ||
| 15 | # Usernames are from 0 to the !... extract it out of we can. | ||
| 16 | if self.prefix.find('!') > -1: | ||
| 17 | return self.prefix[0:self.prefix.index('!')] | ||
| 18 | else: | ||
| 19 | return False | ||
| 20 | |||
| 14 | def _process_data(self, data): | 21 | def _process_data(self, data): |
| 15 | data = data.strip() | 22 | data = data.strip() |
| 16 | 23 | ||
| @@ -20,21 +27,22 @@ class ircparse(object): | |||
| 20 | # colon and the prefix. | 27 | # colon and the prefix. |
| 21 | if data[0] == ':': | 28 | if data[0] == ':': |
| 22 | self.prefix = data[1:].split(' ')[0] | 29 | self.prefix = data[1:].split(' ')[0] |
| 30 | start_at = 1 | ||
| 23 | else: | 31 | else: |
| 24 | # If the prefix is missing from the message, it is assumed to have | 32 | # If the prefix is missing from the message, it is assumed to have |
| 25 | # originated from the connection from which it was received. | 33 | # originated from the connection from which it was received. |
| 26 | # | 34 | # |
| 27 | # TODO: Get the server name from the parent object. | 35 | # TODO: Get the server name from the parent object. |
| 28 | pass | 36 | start_at = 0 |
| 29 | 37 | ||
| 30 | # Command comes 2nd (Or first if the prefix is missing) | 38 | # Command comes 2nd (Or first if the prefix is missing) |
| 31 | if len(data.split(' ')) > 1: | 39 | if len(data.split(' ')) > start_at: |
| 32 | self.command = data.split(' ')[1] | 40 | self.command = data.split(' ')[start_at] |
| 33 | 41 | ||
| 34 | # Finally we reconstruct the parameters. We'll let the plugins figure out | 42 | # Finally we reconstruct the parameters. We'll let the plugins figure out |
| 35 | # what they mean since they could potentially be very different. | 43 | # what they mean since they could potentially be very different. |
| 36 | if len(data.split(' ')) > 2: | 44 | if len(data.split(' ')) > (start_at + 1): |
| 37 | for param in data.split(' ')[2:]: | 45 | for param in data.split(' ')[(start_at+1):]: |
| 38 | self.params += param + " " | 46 | self.params += param + " " |
| 39 | self.params.strip() | 47 | self.params.strip() |
| 40 | 48 | ||