-
-
Save sudosanet/c85a9d92c5d920b9d07a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
require "open-uri" | |
require "uri" | |
require "nokogiri" | |
require 'tweetstream' | |
CONSUMER_KEY = "あなたのCONSUMER_KEY" | |
CONSUMER_SECRET = "あなたのCONSUMER_SECRET" | |
OAUTH_TOKEN = "あなたのOAUTH_TOKEN" | |
OAUTH_TOKEN_SECRET = "あなたのOAUTH_TOKEN_SECRET" | |
YOUR_ID = "あなたのTwitterID (@sudosanなど)" | |
icons=[] | |
url = "http://anime-eupho.com/special/" | |
doc = Nokogiri::HTML.parse(open(url)) | |
doc.css('img').each do |node| | |
path = node.attributes["src"].value | |
next if path !~ /special\/twitter\/thumb/ | |
path.gsub!("thumb","icon").gsub!("jpg","png") | |
icons << "http://anime-eupho.com"+path | |
end | |
begin | |
eupho_twitter = Twitter::REST::Client.new do |cnf| | |
cnf.consumer_key = CONSUMER_KEY | |
cnf.consumer_secret = CONSUMER_SECRET | |
cnf.access_token = OAUTH_TOKEN | |
cnf.access_token_secret = OAUTH_TOKEN_SECRET | |
end | |
tw ="eupho_updateを起動しました、僕にeuphoとリプを送るとアイコンがランダムで変わります \n" + Time.now.to_s | |
eupho_twitter.update tw | |
TweetStream.configure do |cnf| | |
cnf.consumer_key = CONSUMER_KEY | |
cnf.consumer_secret = CONSUMER_SECRET | |
cnf.oauth_token = OAUTH_TOKEN | |
cnf.oauth_token_secret = OAUTH_TOKEN_SECRET | |
cnf.auth_method = :oauth | |
end | |
client = TweetStream::Client.new | |
client.userstream do |status| | |
if status.text.downcase.include?("#{YOUR_ID} eupho") && !status.text.include?("RT") then | |
eupho_twitter.update_profile_image(icons) | |
t = Time.now | |
strTime = t.strftime("%H時 %M分 %S秒") | |
option = {"in_reply_to_status_id"=>status.id.to_s} | |
tweet = ". @#{status.user.screen_name} ユーフォニアムアイコンを" + icons + "に設定しました #killme_icon \n #{strTime}" | |
p tweet | |
eupho_twitter.update tweet,option | |
end | |
end | |
rescue => e | |
STDERR.puts "[EXCEPTION] " + e.to_s | |
exit 1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment