aboutsummaryrefslogtreecommitdiff
path: root/admin.rb
blob: 3fc033861f227ad41827629c3819c6b9605e924d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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