From 041d4f55f87b167dcab8b752824f6cc348da8b77 Mon Sep 17 00:00:00 2001 From: Daniel Muckerman Date: Fri, 27 Jul 2018 20:19:52 -0400 Subject: [PATCH] Remove old route for image path and just use og embed url --- slack-pixiv/commands/illust.rb | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/slack-pixiv/commands/illust.rb b/slack-pixiv/commands/illust.rb index b047d6b..e546b90 100644 --- a/slack-pixiv/commands/illust.rb +++ b/slack-pixiv/commands/illust.rb @@ -37,24 +37,7 @@ module SlackMathbot puts title # Scrape image - image_url = agent.get(pixiv_url).images_with(:src => /600x600\/img-master/)[0].to_s.sub! '600x600','480x960' - begin - # Attempt to check on image - page = agent.get(image_url) - - # Make sure page came back kosher - if page.code.to_i == 200 - # Image url is fine - puts "Image is good to go!" - else - # Fallback on http error to be safe - image_url = "https://embed.pixiv.net/decorate.php?illust_id=" + pixiv_url[/\d+/] - end - rescue Mechanize::ResponseCodeError - # Fallback to og:image url - puts "Image failed to load" - image_url = "https://embed.pixiv.net/decorate.php?illust_id=" + pixiv_url[/\d+/] - end + image_url = "https://embed.pixiv.net/decorate.php?illust_id=" + pixiv_url[/\d+/] puts image_url client.web_client.chat_postMessage(