aboutsummaryrefslogtreecommitdiff
path: root/dinobot.rb
diff options
context:
space:
mode:
Diffstat (limited to 'dinobot.rb')
-rw-r--r--dinobot.rb20
1 files changed, 15 insertions, 5 deletions
diff --git a/dinobot.rb b/dinobot.rb
index 02c2184..947dfcd 100644
--- a/dinobot.rb
+++ b/dinobot.rb
@@ -107,14 +107,24 @@ module Dinobot
end
def load_module(mod)
- file = Dir.entries(File.dirname(__FILE__)).find { |x| x == mod.to_s.downcase + ".rb" }
+ mod = mod.downcase
+ puts "== Loading module: #{mod}."
- if file
- puts "== Loading #{mod}."
+ file = Dir.entries(File.dirname(__FILE__))
+ .find { |x| x == mod.to_s + ".rb" }
- load file
- @modules[mod.downcase] = eval("Dinobot::#{mod}").new
+ unless file
+ puts "== Failed to load module: #{mod} (File #{mod}.rb not found)."
+
+ return false
end
+
+ load file
+
+ m = Dinobot.const_get(Dinobot.constants.find { |x| x.downcase == mod })
+ @modules[mod] = m.new
+
+ puts "== Loaded module: #{mod} (#{m})."
end
end
end