aboutsummaryrefslogtreecommitdiff
path: root/module
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2014-04-21 05:16:29 -0700
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2014-04-21 05:16:29 -0700
commit349371e4c13e619b787fb4ab5a3dfcde95fd355e (patch)
tree49a45f6f0f672745dfdce19f4003f5f3c54870cf /module
parent39dfb870d9a54d63f24a150e995b6da44f81ba43 (diff)
downloaddinobot-349371e4c13e619b787fb4ab5a3dfcde95fd355e.tar.gz
dinobot-349371e4c13e619b787fb4ab5a3dfcde95fd355e.tar.xz
Persistent storing of admin list (allows reload).
Diffstat (limited to 'module')
-rw-r--r--module/admin.rb24
1 files changed, 17 insertions, 7 deletions
diff --git a/module/admin.rb b/module/admin.rb
index f700a74..768d4f6 100644
--- a/module/admin.rb
+++ b/module/admin.rb
@@ -1,4 +1,5 @@
require_relative 'base'
+require_relative '../core/store'
module Dinobot
module Module
@@ -6,18 +7,27 @@ module Dinobot
def initialize(bot)
super
+ @store = Dinobot::Core::Store.new('data/admin')
+
@commands << :join << :part << :quit << :load << :unload
@commands << :listadmins << :listmodules << :listchannels
- @admins = Array.new
+ @admins = @store.data[:admins]
+ @admins ||= Array.new
end
def add(user)
@admins << user unless @admins.include?(user)
+
+ @store.data[:admins] = @admins
+ @store.save
end
def remove(user)
@admins.delete(user)
+
+ @store.data[:admins] = @admins
+ @store.save
end
def is_admin?(user)
@@ -43,12 +53,6 @@ module Dinobot
[[:quit, argument ? argument.strip : 'Quitting.']]
end
- def listadmins(user, channel, argument)
- return unless is_admin?(user)
-
- [[:say, channel, @admins.join(' ')]]
- end
-
def load(user, channel, argument)
return unless is_admin?(user)
@@ -69,6 +73,12 @@ module Dinobot
nil
end
+ def listadmins(user, channel, argument)
+ return unless is_admin?(user)
+
+ [[:say, channel, @admins.join(' ')]]
+ end
+
def listmodules(user, channel, argument)
return unless is_admin?(user)