Sha256: 4d03ba9b308a4aafb8df6587011038a1d59d189627e22b61b0ca13f1ef550c0e
Contents?: true
Size: 630 Bytes
Versions: 1
Compression:
Stored size: 630 Bytes
Contents
require "lita" require 'open-uri' require 'nokogiri' module Lita module Handlers class RedditImagePreview < Handler route %r{https://www.reddit.com/r/}i, :reddit_image_preview, command: true def reddit_image_preview(response) html = open(response[0], 'User-Agent' => 'lita') # puts html.read doc = Nokogiri::HTML(html.read) if doc.css('img.media-element')[0] # puts doc.css('img.media-element')[0].attr('src') 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.1 | lib/lita/handlers/reddit_image_preview.rb |