aboutsummaryrefslogtreecommitdiff
path: root/core/messageinfo.rb
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2014-04-21 14:17:44 -0700
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2014-04-21 14:17:44 -0700
commited04bd3c0fff100f40ed45d300fcb152723226ef (patch)
treebe80f6bc8370126e899a7b53be6fa319a3b1c2af /core/messageinfo.rb
parent8fd8c27562184a18000d32d96921fbb0ca8045be (diff)
downloaddinobot-ed04bd3c0fff100f40ed45d300fcb152723226ef.tar.gz
dinobot-ed04bd3c0fff100f40ed45d300fcb152723226ef.tar.xz
Move response validation out of main code.
Diffstat (limited to 'core/messageinfo.rb')
-rw-r--r--core/messageinfo.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/core/messageinfo.rb b/core/messageinfo.rb
index 4499bdc..627ca90 100644
--- a/core/messageinfo.rb
+++ b/core/messageinfo.rb
@@ -9,6 +9,21 @@ module Dinobot
@message = message
@response = []
end
+
+ def respond(arr)
+ raise "response not array -- #{arr}" unless arr.is_a?(Array)
+
+ case arr.first
+ when :say
+ raise "wrong number of arguments -- #{arr}" unless arr.length == 3
+ when :join, :part, :quit
+ raise "wrong number of arguments -- #{arr}" unless arr.length == 2
+ else
+ raise "unknown method name -- #{arr}"
+ end
+
+ @response << arr
+ end
end
end
end