rubyでTwitterのメンションを待ち受ける

require 'tweetstream'

TweetStream.configure do |config|
  config.consumer_key       = 'xxx'
  config.consumer_secret    = 'xxx'
  config.oauth_token        = 'xxx'
  config.oauth_token_secret = 'xxx'
  config.auth_method        = :oauth
end

client = TweetStream::Client.new
client.userstream do |status|
    if /@YOUR_USERNAME/.match(status.text) #自分へのメンションであれば
      content = status.text.gsub(/@[a-zA-Z0-9_]+\s/,"") #ユーザー名を削除(複数人メンションに対応)
      puts content
    end
end