From bd8befe08476d89287292e141e054ec18df50deb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Mon, 30 Jun 2008 11:51:15 +0200 Subject: [PATCH] Use plugin.map to register the host command. Instead of just registering the plugin and then doing the parameter check in the function, use the plugin.map function and declare the requirement for the parameter passed. --- data/rbot/plugins/host.rb | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/data/rbot/plugins/host.rb b/data/rbot/plugins/host.rb index c5fbcdaa..34b0356f 100644 --- a/data/rbot/plugins/host.rb +++ b/data/rbot/plugins/host.rb @@ -11,13 +11,9 @@ class HostPlugin < Plugin @bot.config["host.path"] end - def privmsg(m) - unless(m.params =~ /^(\w|-|\.)+$/) - m.reply "incorrect usage: " + help(m.plugin) - return - end - m.reply Utils.safe_exec(host_path, m.params) + def host(m, params) + m.reply Utils.safe_exec(host_path, params[:name]) end end plugin = HostPlugin.new -plugin.register("host") +plugin.map 'host :name', :requirements => {:name => /^((\w|-|\.)+)$/} -- 2.32.0.93.g670b81a890