diff options
author | Yaohan Chen <yaohan.chen@gmail.com> | 2007-11-26 04:25:19 +0000 |
---|---|---|
committer | Yaohan Chen <yaohan.chen@gmail.com> | 2007-11-26 04:25:19 +0000 |
commit | 02d0166ba355be0419c39eea85f9f8dcf13f04d9 (patch) | |
tree | d254d1f4b0d9bfbf315c73e6b4e4a1cf980dba52 /data/rbot | |
parent | 1ff0b683756532ff07023a7c17529c6a32cd3e99 (diff) |
alias.rb:
* fix bug in alias checking code which prevented aliases with more than one
parameters
+ reply with error message if mapping alias fails
Diffstat (limited to 'data/rbot')
-rw-r--r-- | data/rbot/plugins/alias.rb | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/data/rbot/plugins/alias.rb b/data/rbot/plugins/alias.rb index 289ef1ad..3339db7f 100644 --- a/data/rbot/plugins/alias.rb +++ b/data/rbot/plugins/alias.rb @@ -109,12 +109,17 @@ class AliasPlugin < Plugin # each alias is implemented by adding a message map, whose handler creates a message # containing the aliased command - command.grep(/<(\w+)>/) {$1}.to_set == - text.grep(/(?:^|\s)[:*](\w+)(?:\s|$)/) {$1}.to_set or + command.scan(/<(\w+)>/).flatten.to_set == + text.split.grep(/\A[:*](\w+)\Z/) {$1}.to_set or raise AliasDefinitionError.new(_('The arguments in alias must match the substitutions in command, and vice versa')) + begin + map text, :action => :"alias_handle<#{text}>", :auth_path => 'run' + rescue + raise AliasDefinitionError.new(_('Error mapping %{text} as command: %{error}') % + {:text => text, :error => $!}) + end @aliases[text] = command - map text, :action => :"alias_handle<#{text}>", :auth_path => 'run' end def respond_to?(name, include_private=false) |