summaryrefslogtreecommitdiffstats
path: root/modules/Fortune.rb
blob: 2d4436b9101d20e1531fe85276cb85c505b9a711 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
require 'xmpp4r/message'

require_relative '../module_base'

module Lain
  module Modules
    class Fortune < Base
      def on_message(muc, message)
        return unless /\A!fortune\b/ =~ message.body

        muc.say("\nBEGIN FORTUNE COOKIE\n" + IO.popen(@config[:command]).read.chomp + "\nEND FORTUNE COOKIE")
      end

      def commands
        {
          '!fortune' => 'fortune cookies'
        }
      end
    end
  end
end