Sha256: 23bb513b39a0434499fa77154957672c9e3febb47309eee26cf9bba1652165da

Contents?: true

Size: 698 Bytes

Versions: 3

Compression:

Stored size: 698 Bytes

Contents

# This plugin is brought to you by aburdette/cinch-fmylife
# Thank You!

module Plugins
  class Fml
    include Cinch::Plugin
    include Cinch::Helpers

    enable_acl(:nobody)

    set(
        plugin_name: "FuckMyLife",
        help: "Get a random FML.\nUsage: `?fml`",
    )

    match /fml/

    def execute(m)
      m.reply fetch_random_fml, true
    end

    private
    def fetch_random_fml
      url = 'http://www.fmylife.com/random'

      html_body = RestClient.get(url).body

      fml_story = Nokogiri.HTML(html_body).at('article').text.strip
      fml_story[/^Today, (.+) FML/]
    rescue => e
      e.message
    end
  end
end

# AutoLoad
Bot.config.plugins.plugins.push Plugins::Fml

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
zetabot-2.1.2 lib/Zeta/plugins/fml.rb
zetabot-2.1.1 lib/Zeta/plugins/fml.rb
zetabot-2.1.0 lib/Zeta/plugins/fml.rb