From 68e6ce01b5baa7edead559cdcd8b512ebb7e8fc2 Mon Sep 17 00:00:00 2001 From: Daniel Muckerman Date: Tue, 5 Apr 2016 16:28:11 -0400 Subject: [PATCH] Change regex to catch based on instead, narrowing the potential matches --- slack-pixiv/commands/pixiv.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/slack-pixiv/commands/pixiv.rb b/slack-pixiv/commands/pixiv.rb index 4ded290..cb6bd42 100644 --- a/slack-pixiv/commands/pixiv.rb +++ b/slack-pixiv/commands/pixiv.rb @@ -2,13 +2,19 @@ module SlackMathbot module Commands class Pixiv < SlackRubyBot::Commands::Base - match /pixiv\.net(?.*)$/ do |client, _data, _match| + match /member_illust\.php(?.*)$/ do |client, _data, _match| # Initalize Mechanize agent = Mechanize.new # Create Pixiv URL - pixiv_url = "http://www.pixiv.net" + _match[:url][0..-2] + # If a full URL is given, extra characters are appended for some reason. + # This ensures we catch them better + if (_data[:text].include? "pixiv.net") + pixiv_url = "http://www.pixiv.net/member_illust.php" + _match[:url][0..-2] + else + pixiv_url = "http://www.pixiv.net/member_illust.php" + _match[:url][0..-1] + end puts pixiv_url # Create iOS Illustration URL, regex pixiv_url to