From acc8aebe98593e3e0ea6938fe2c3512472c0da91 Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Mon, 14 Apr 2014 02:54:25 -0700 Subject: Check for trigger (and strip before command call). --- dinobot.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/dinobot.rb b/dinobot.rb index 464f299..02c2184 100644 --- a/dinobot.rb +++ b/dinobot.rb @@ -59,10 +59,14 @@ module Dinobot if str =~ /(\S+) PRIVMSG (\S+) :(.*)/ user, channel, message = str.scan(/(\S+) PRIVMSG (\S+) :(.*)/).first - if @modules.has_key?(message.split.first.sub(/^#{Regexp.escape(@trigger)}/, '').downcase.intern) - ret = @modules[message.split.first.sub(/^#{Regexp.escape(@trigger)}/, '').downcase.intern].call(user, channel, message) + if message =~ /^#{Regexp.escape(@trigger)}/ + message.sub!(@trigger, '') - exec_commands(ret) + mod = message.split.first.downcase.intern + + if @modules.has_key?(mod) + exec_commands(@modules[mod].call(user, channel, message)) + end end end end -- cgit v1.2.3-70-g09d2