Skip to content

Commit

Permalink
Fixed named parameters in the command regex and added a check for nam…
Browse files Browse the repository at this point in the history
…ed/unnamed combinations
  • Loading branch information
CarlosFdez committed Aug 12, 2012
1 parent 1fd6a9e commit 6d96a7c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pyrc/bots.py
Expand Up @@ -123,7 +123,16 @@ def parsecommand(self, channel, message):
for command_func in self._commands:
match = command_func._matcher.search(command)
if match:
command_func(self, channel, *match.groups(), **match.groupdict())
group_dict = match.groupdict()
groups = match.groups()
if group_dict and (len(groups) > len(group_dict)):
# match.groups() also returns named parameters
raise "You cannot use both named and unnamed parameters"
elif group_dict:
command_func(self, channel, **group_dict)
else:
command_func(self, channel, *groups)

if self.config['break_on_match']: break

def name_used(self, message):
Expand Down

0 comments on commit 6d96a7c

Please sign in to comment.