diff options
author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2014-04-14 02:54:25 -0700 |
---|---|---|
committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2014-04-14 02:54:25 -0700 |
commit | acc8aebe98593e3e0ea6938fe2c3512472c0da91 (patch) | |
tree | 8328874c7e940d453f055dd3d0927c8149a245e8 /dinobot.rb | |
parent | 36ae5303a60a19dd3ad4c84f882ca893cce0d0e2 (diff) | |
download | dinobot-acc8aebe98593e3e0ea6938fe2c3512472c0da91.tar.gz dinobot-acc8aebe98593e3e0ea6938fe2c3512472c0da91.tar.xz |
Check for trigger (and strip before command call).
Diffstat (limited to 'dinobot.rb')
-rw-r--r-- | dinobot.rb | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -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 |