Skip to content

Instantly share code, notes, and snippets.

@erutaso
Created March 28, 2014 16:54
Show Gist options
  • Save erutaso/9837514 to your computer and use it in GitHub Desktop.
Save erutaso/9837514 to your computer and use it in GitHub Desktop.
def change_icon(status)
#streamingから@user_name change_iconを見つけたら以下を実行する
if status.text.include?("@#{@name} change_icon") then
#画像が入ってるディレクトリからランダムに取ってくる。パスは各自変更
p = Dir::entries('./icon').sample
#ランダムに選ばれた画像を開く(よくわからん)
pic = open("./icon/#{p}", "r")
p pic
#iconを変更
@rest_client.update_profile_image(pic)
#replyと変更したよというツイート内容
opt = {"in_reply_to_status_id"=>status.id.to_s}
tweet = "@#{status.user.screen_name} change #{p}"
#上記をツイート
@rest_client.update tweet,opt
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment