aboutsummaryrefslogtreecommitdiff
path: root/module/base.rb
blob: 3d048951a1a0b22b335684d893c02d92f019854e (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
module Dinobot
  module Module
    class Base
      attr_accessor :commands

      def initialize(bot)
        @bot = bot

        @commands = [:commands]
      end

      def call(m, command)
        command, args = command.split(' ', 3)[1..2]
        args ||= ''

        return unless @commands.map { |x| x.to_s }.include?(command)

        send(command, m, args)
      end

      def commands(m, args)
        m.respond [:say, m.channel,
          "Commands: #{@commands.sort.join(' ')}"]
      end
    end
  end
end