aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2014-04-14 02:54:25 -0700
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2014-04-14 02:54:25 -0700
commitacc8aebe98593e3e0ea6938fe2c3512472c0da91 (patch)
tree8328874c7e940d453f055dd3d0927c8149a245e8
parent36ae5303a60a19dd3ad4c84f882ca893cce0d0e2 (diff)
downloaddinobot-acc8aebe98593e3e0ea6938fe2c3512472c0da91.tar.gz
dinobot-acc8aebe98593e3e0ea6938fe2c3512472c0da91.tar.xz
Check for trigger (and strip before command call).
-rw-r--r--dinobot.rb10
1 files 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