summaryrefslogtreecommitdiffstats
path: root/modules/Fortune.rb
blob: 9a762b44a969023428f1a2502c2f36d41adcab5e (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