diff options
author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2014-04-20 04:23:20 -0700 |
---|---|---|
committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2014-04-20 04:23:20 -0700 |
commit | 7f134adccb20abe773234acecf526c9951b418e8 (patch) | |
tree | eeb4b4f96a963591f244c8f661b84dd194cf1484 /admin.rb | |
parent | 7e7aa3278a9e478b02eb152575fb00ee0802ac81 (diff) | |
download | dinobot-7f134adccb20abe773234acecf526c9951b418e8.tar.gz dinobot-7f134adccb20abe773234acecf526c9951b418e8.tar.xz |
Improved namespace and directory structure.
Diffstat (limited to 'admin.rb')
-rw-r--r-- | admin.rb | 77 |
1 files changed, 0 insertions, 77 deletions
diff --git a/admin.rb b/admin.rb deleted file mode 100644 index c505ef0..0000000 --- a/admin.rb +++ /dev/null @@ -1,77 +0,0 @@ -require_relative 'module' - -module Dinobot - class Admin < Module - def initialize(bot) - super - - @commands << :join << :part << :load << :unload - @commands << :listadmins << :listmodules << :listchannels - - @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) - return unless is_admin?(user) - - [[:join, argument.strip]] - end - - def part(user, channel, argument) - return unless is_admin?(user) - - [[:part, argument.strip]] - 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) - - argument.split.each do |x| - @bot.load_module x.intern - end - - nil - end - - def unload(user, channel, argument) - return unless is_admin?(user) - - argument.split.each do |x| - @bot.unload_module x.intern - end - - nil - end - - def listmodules(user, channel, argument) - return unless is_admin?(user) - - [[:say, channel, "Modules: #{@bot.modules.keys.sort.join(' ')}"]] - end - - def listchannels(user, channel, argument) - return unless is_admin?(user) - - [[:say, channel, "Channels: #{@bot.channels.sort.join(' ')}"]] - end - end -end |