Sha256: 407fcb16cacce399f1e07752225321440d95741a81b54373b6eb2cd54da52d5e

Contents?: true

Size: 571 Bytes

Versions: 1

Compression:

Stored size: 571 Bytes

Contents

require "nokogiri"

module Isis
  module Plugin
    class Bash < Isis::Plugin::Base
      def respond_to_msg?(msg, speaker)
        /\b!bash\b/i =~ msg
      end

      private

      def response_text
        page = Nokogiri.HTML(open('http://bash.org?random1'))
        selected = rand(page.css('.quote').length)
        link = page.css('.quote')[selected].css('a').first['href']
        quote = page.css('.qt')[selected].text
        number = link.gsub('?', '')
        "bash.org ##{number}: \r\n#{quote}\r\n(link: http://bash.org#{link})"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
isis-plugin-bash-1.0.0 lib/isis/plugin/bash.rb