|
|
@ -7,9 +7,6 @@ module SlackMathbot |
|
|
|
# Initalize Mechanize |
|
|
|
agent = Mechanize.new |
|
|
|
|
|
|
|
# Get time |
|
|
|
time = Time.now |
|
|
|
|
|
|
|
# Create Pixiv URL |
|
|
|
pixiv_url = "http://www.pixiv.net" + _match[:url][0..-2] |
|
|
|
puts pixiv_url |
|
|
@ -30,23 +27,8 @@ module SlackMathbot |
|
|
|
puts title |
|
|
|
|
|
|
|
# Scrape image |
|
|
|
r = Range.new( |
|
|
|
Time.local(time.year, time.month, time.day, 12), |
|
|
|
Time.local(time.year, time.month, time.day, 20) |
|
|
|
) === time |
|
|
|
|
|
|
|
if ((Date.today.to_s == "2016-04-01") && (r)) |
|
|
|
api_url = "http://rule34.paheal.net/api/danbooru/find_posts/index.xml" |
|
|
|
|
|
|
|
agent.get(api_url) |
|
|
|
xml = agent.current_page.body |
|
|
|
status = XmlSimple.xml_in(xml) |
|
|
|
image_url = status["post"].sample["file_url"] |
|
|
|
puts agent.get(pixiv_url).images_with(:src => /600x600\/img-master/)[0].to_s.sub! '600x600','480x960' |
|
|
|
else |
|
|
|
image_url = agent.get(pixiv_url).images_with(:src => /600x600\/img-master/)[0].to_s.sub! '600x600','480x960' |
|
|
|
puts image_url |
|
|
|
end |
|
|
|
image_url = agent.get(pixiv_url).images_with(:src => /600x600\/img-master/)[0].to_s.sub! '600x600','480x960' |
|
|
|
puts image_url |
|
|
|
|
|
|
|
client.web_client.chat_postMessage( |
|
|
|
channel: _data.channel, |
|
|
|