diff options
author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2014-04-14 05:12:50 -0700 |
---|---|---|
committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2014-04-14 05:12:50 -0700 |
commit | 376b34ee7249525b0adb49e8c8043ab2fa0d8347 (patch) | |
tree | ec556bdaf918fee658675d701b75dc02c385117a | |
parent | 282b36e2690aea415244c81eadf093c41f752194 (diff) | |
download | dinobot-376b34ee7249525b0adb49e8c8043ab2fa0d8347.tar.gz dinobot-376b34ee7249525b0adb49e8c8043ab2fa0d8347.tar.xz |
Rename Echo to Test and add error testing.
-rw-r--r-- | dinobot.rb | 9 | ||||
-rw-r--r-- | example.rb | 2 | ||||
-rw-r--r-- | test.rb (renamed from echo.rb) | 8 |
3 files changed, 11 insertions, 8 deletions
@@ -46,7 +46,8 @@ module Dinobot begin parse_line(str) - rescue + rescue => e + puts "== Error parsing line. (#{e})" end end @@ -111,17 +112,15 @@ module Dinobot mod = mod.downcase.intern puts "== Loading module: #{mod}" - file = "#{mod}.rb" - begin - load file + load "#{mod}.rb" m = Dinobot.const_get(Dinobot.constants.find { |x| x.downcase == mod }) @modules[mod] = m.new puts "== Loaded module: #{mod} (#{m})" rescue LoadError, StandardError => e - puts "== Failed to load module: #{mod} (#{e.message})" + puts "== Failed to load module: #{mod} (#{e})" end end @@ -5,7 +5,7 @@ require_relative 'dinobot' bot = Dinobot::Bot.new('irc.example.org', 6667, 'dinobot') do join '#dinobot' - load_module :echo + load_module :test end loop do @@ -1,15 +1,19 @@ require_relative 'module' module Dinobot - class Echo < Module + class Test < Module def initialize super - @commands << :echo + @commands << :echo << :error end def echo(user, channel, argument) [[:say, channel, argument]] end + + def error(user, channel, argument) + x + end end end |