Skip to content

Instantly share code, notes, and snippets.

@rigibun
Created July 29, 2014 07:25
Show Gist options
  • Save rigibun/2efa278c43ae56c2aa6f to your computer and use it in GitHub Desktop.
Save rigibun/2efa278c43ae56c2aa6f to your computer and use it in GitHub Desktop.
require 'twitter'
require 'pp'
client = Twitter::REST::Client.new do |config|
config.consumer_key = 'CK'
config.consumer_secret = 'CS'
config.access_token = 'AT'
config.access_token_secret = 'AS'
end
myId = client.settings.screen_name
re = Regexp.new "(.*)\\(@#{myId}\\)"
mentions = client.mentions
sinceId = mentions[0].id
loop do
name = nil
mentions.each do |mention|
text = mention.text
if text =~ re
name = $1
print "matched", text, "\n"
puts name
if name.length <= 20
break
end
end
end
if name and name.length <= 20
client.update_profile(:name => name)
status = "[update_name] #{name}"
client.update(status)
puts status
end
sleep 60
mentions = client.mentions_timeline(:since_id => sinceId)
sinceId = mentions[0].id if mentions.size > 0
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment