diff options
author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2014-04-21 06:51:06 -0700 |
---|---|---|
committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2014-04-21 06:51:06 -0700 |
commit | fbff2860e9ba2e11794ec627db224d92b16a8c4d (patch) | |
tree | f773ffd9d01c7be09c6bd99c5970bebda83deb75 /module | |
parent | 27c066998bea20387d4c33e504145496aad1b344 (diff) | |
download | dinobot-fbff2860e9ba2e11794ec627db224d92b16a8c4d.tar.gz dinobot-fbff2860e9ba2e11794ec627db224d92b16a8c4d.tar.xz |
Add configuration interface module.
Diffstat (limited to 'module')
-rw-r--r-- | module/config.rb | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/module/config.rb b/module/config.rb new file mode 100644 index 0000000..2bf8b0b --- /dev/null +++ b/module/config.rb @@ -0,0 +1,53 @@ +require_relative 'base' +require_relative '../core/config' + +module Dinobot + module Module + class Config < Base + def initialize(bot) + super + + @config = Dinobot::Core::Config.instance + + @commands << :get << :set + end + + def get(user, channel, argument) + return unless @bot.modules[:admin].is_admin?(user) + + case argument + when 'trigger' + [[:say, channel, @config.data[:trigger][:global]]] + when 'debug' + [[:say, channel, @config.data[:debug].to_s]] + else + nil + end + end + + def set(user, channel, argument) + return unless @bot.modules[:admin].is_admin?(user) + + key, val = argument.split(' ') + return unless val + + case key + when 'trigger' + @config.data[:trigger][:global] = val + @config.save + when 'debug' + case val + when 'true' + @config.data[:debug] = true + @config.save + when 'false' + @config.data[:debug] = false + @config.save + end + end + + nil + end + end + end +end |