Last active
December 12, 2015 07:28
-
-
Save kimihito/4736280 to your computer and use it in GitHub Desktop.
ちくわぶの画像をつけてつぶやく。 橋本商会 » ネタ画像検索No.1 tiqav.com のrubygemとか作った
http://shokai.org/blog/archives/6149 https://github.com/shokai/ruby-tiqav
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
#-*- coding: utf-8 -*- | |
require 'rubygems' | |
require 'tiqav' | |
require 'twitter' | |
require 'open-uri' | |
require 'tempfile' | |
Twitter.configure do |config| | |
config.consumer_key = "YOUR_CONSUMER_KEY" | |
config.consumer_secret = "YOUR_CONSUMER_SECRET" | |
config.oauth_token = "YOUR_OAUTH_TOKEN" | |
config.oauth_token_secret = "YOUR_OAUTH_TOKEN_SECRET" | |
end | |
tweet = ARGV[0] | |
def tiqav_file(text) | |
image = open(Tiqav.search(text).shuffle.first.url) | |
Tempfile.open('tiqav'){|file| file.write image.read; file} | |
end | |
Twitter.update_with_media(tweet + " #ちくわぶったー", open(tiqav_file(tweet).path)) | |
puts "posted" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment