「眠い」と呟いた最新20ツイートに非公式RTで「起きろ!」と呟いてみる。
require 'yaml' require 'rubygems' require 'twitter' conf_file='conf.yml' @conf = YAML::load(File.read(conf_file)) # p @conf Twitter.configure do |config| oauth_bot_conf = @conf['bot']['oauth'] config.consumer_key = oauth_bot_conf['consumer_key'] config.consumer_secret = oauth_bot_conf['consumer_secret'] config.oauth_token = oauth_bot_conf['token'] config.oauth_token_secret = oauth_bot_conf['secret'] end client = Twitter::Client.new search = Twitter::Search.new search.containing("眠い").result_type("recent").per_page(20).each do |r| msg = "起きろ! RT @#{r.from_user}: #{r.text}" puts msg.size if msg.length < 240 puts msg client.update( msg) end end