aboutsummaryrefslogtreecommitdiff
path: root/module
diff options
context:
space:
mode:
Diffstat (limited to 'module')
-rw-r--r--module/config.rb53
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