Sha256: fb012045cde9d636ff6af46e7f48c6efe1807eb640cf7e5478fa99289466b00e
Contents?: true
Size: 551 Bytes
Versions: 1
Compression:
Stored size: 551 Bytes
Contents
require "lita" require 'open-uri' require 'nokogiri' module Lita module Handlers class RedditImagePreview < Handler route %r{reddit.com/r/}i, :reddit_image_preview, command: false def reddit_image_preview(response) html = open(response.message.body, 'User-Agent' => 'lita') doc = Nokogiri::HTML(html.read) if doc.css('img.media-element').length > 0 response.reply doc.css('img.media-element')[0].attr('src') end end end Lita.register_handler(RedditImagePreview) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lita-reddit-image-preview-1.0.3 | lib/lita/handlers/reddit_image_preview.rb |