aboutsummaryrefslogtreecommitdiff
path: root/admin.rb
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2014-04-14 05:48:01 -0700
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2014-04-14 05:48:01 -0700
commit29cc359a91d8f73f9a2f4e47646e691bfe117346 (patch)
tree6708940a2a4f848e53bba6fb1c265a778651c57c /admin.rb
parent376b34ee7249525b0adb49e8c8043ab2fa0d8347 (diff)
downloaddinobot-29cc359a91d8f73f9a2f4e47646e691bfe117346.tar.gz
dinobot-29cc359a91d8f73f9a2f4e47646e691bfe117346.tar.xz
Add very basic admin support.
Diffstat (limited to 'admin.rb')
-rw-r--r--admin.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/admin.rb b/admin.rb
new file mode 100644
index 0000000..3fc0338
--- /dev/null
+++ b/admin.rb
@@ -0,0 +1,34 @@
+require_relative 'module'
+
+module Dinobot
+ class Admin < Module
+ def initialize
+ super
+
+ @commands << :join << :part
+
+ @admins = Array.new
+ end
+
+ def add(user)
+ @admins << user unless @admins.include?(user)
+ end
+
+ def remove(user)
+ @admins.delete(user)
+ end
+
+ def is_admin?(user)
+ # FIXME: Using hostname for testing purposes. Need better solution.
+ @admins.include?(user.sub(/.+@/, ''))
+ end
+
+ def join(user, channel, argument)
+ [[:join, argument]] if is_admin?(user)
+ end
+
+ def part(user, channel, argument)
+ [[:part, argument]] if is_admin?(user)
+ end
+ end
+end