Class: Lita::Handlers::OnewheelUnstagram

Inherits:
Handler
  • Object
show all
Defined in:
lib/lita/handlers/onewheel_unstagram.rb

Instance Method Summary collapse

Instance Method Details

#handle_unstagram(response) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/lita/handlers/onewheel_unstagram.rb', line 8

def handle_unstagram(response)
  fetch_url = response.matches[0][0]
  Lita.logger.info("Fetching #{fetch_url}")

  resp = RestClient.get(fetch_url)
  quick_down = fetch_url

  if m = /window._sharedData = ({.*})\;/.match(resp)
    json = JSON.parse m[1]
    quick_down += " #{json['entry_data']['PostPage'][0]['graphql']['shortcode_media']['display_url']}"
  end

  response.reply quick_down
end