Skip to content

Instantly share code, notes, and snippets.

@uhfx
Forked from sasamijp/namechanger.rb
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uhfx/8910203 to your computer and use it in GitHub Desktop.
Save uhfx/8910203 to your computer and use it in GitHub Desktop.
# -*- encoding: utf-8 -*-
require 'rubygems'
require 'tweetstream'
require 'twitter'
require './key.rb'
Twitter.configure do |config|
config.consumer_key = Const::CONSUMER_KEY
config.consumer_secret = Const::CONSUMER_SECRET
config.oauth_token = Const::ACCESS_TOKEN
config.oauth_token_secret = Const::ACCESS_TOKEN_SECRET
end
TweetStream.configure do |config|
config.consumer_key = Const::CONSUMER_KEY
config.consumer_secret = Const::CONSUMER_SECRET
config.oauth_token = Const::ACCESS_TOKEN
config.oauth_token_secret = Const::ACCESS_TOKEN_SECRET
config.auth_method = :oauth
end
#Twitter.update_profile(:name => "test")
client = TweetStream::Client.new
client.userstream do |status|
if status.text.include?("(@uh700)") && !status.text.include?("RT") then
text = status.text.sub("(@uh700)","")
text = text.sub("@","")
Twitter.update_profile(:name => "#{text}")
option = {"in_reply_to_status_id"=>status.id.to_s}
tweet = "@#{status.user.screen_name} #名前が{text}になりました"
Twitter.update tweet,option
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment