diff options
author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2014-04-21 14:48:09 -0700 |
---|---|---|
committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2014-04-21 14:48:09 -0700 |
commit | 7f94ea0c30bee85c0eecbd4ccb4c8e7efb3889bb (patch) | |
tree | c3520d0727314bff2dbfac006743672f825f605d /dinobot.rb | |
parent | 211018e2f94c60fdf7a47b87cbcb07432f0fa25d (diff) | |
download | dinobot-7f94ea0c30bee85c0eecbd4ccb4c8e7efb3889bb.tar.gz dinobot-7f94ea0c30bee85c0eecbd4ccb4c8e7efb3889bb.tar.xz |
Add simple getter/setter methods to Store.
Diffstat (limited to 'dinobot.rb')
-rw-r--r-- | dinobot.rb | 23 |
1 files changed, 12 insertions, 11 deletions
@@ -98,16 +98,16 @@ module Dinobot end def add_alias(from, to) - @aliases.data[:global] = Hash.new unless @aliases.data[:global] + @aliases[:global] = Hash.new unless @aliases[:global] - @aliases.data[:global][from] = to + @aliases[:global][from] = to @aliases.save end def remove_alias(from) - return unless @aliases.data[:global] + return unless @aliases[:global] - @aliases.data[:global].delete(from) + @aliases[:global].delete(from) @aliases.save end @@ -134,10 +134,10 @@ module Dinobot m = Dinobot::Core::MessageInfo.new(user, channel, message) return unless message =~ - /\A#{Regexp.escape(@config.data[:trigger][:global])}/ + /\A#{Regexp.escape(@config[:trigger][:global])}/ command = message - .sub(/\A#{Regexp.escape(@config.data[:trigger][:global])}/, '') + .sub(/\A#{Regexp.escape(@config[:trigger][:global])}/, '') exec_command(m, command) process_response(m) if m.response? @@ -146,8 +146,8 @@ module Dinobot def exec_command(m, command) # FIXME: Improve and add debug output. - if @aliases.data[:global] - @aliases.data[:global].each do |k, v| + if @aliases[:global] + @aliases[:global].each do |k, v| command.sub!(/\A#{Regexp.escape(k)}\b/, v) end end @@ -159,11 +159,12 @@ module Dinobot mod = mod.intern if m.response? - prev = m.response + tmp = m.response m.response = [] - prev.each do |x| + tmp.each do |x| if x.first == :say + # FIXME: Retain original channel value? @modules[mod].call(m, "#{command} #{x[2]}") else m.respond x @@ -178,7 +179,7 @@ module Dinobot def process_response(m) m.response.each do |x| - @logger.info "Executing method: #{x.inspect}" if @config.data[:debug] + @logger.info "Executing method: #{x.inspect}" if @config[:debug] send(*x) end end |