http://twitter.com/shokai_log を使って、部屋の気温が低い時に警告する
Created
October 26, 2012 12:42
-
-
Save shokai/3958552 to your computer and use it in GitHub Desktop.
気温が低いときに警告を出す
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| # -*- coding: utf-8 -*- | |
| require 'rubygems' | |
| require 'tw' | |
| require 'json' | |
| threshold = 20 | |
| client = Tw::Client.new | |
| client.auth | |
| tweets = client.user_timeline('shokai_log').sort{|a,b| | |
| b.time <=> a.time | |
| }.map{|m| | |
| JSON.parse m.text rescue nil | |
| }.select{|m| | |
| m.kind_of? Hash and [Fixnum, Float].include? m["気温"].class | |
| } | |
| p tweets | |
| temp = tweets[0]["気温"] | |
| puts "現在の気温 #{temp}度" | |
| system "saykana 'げんざいのきおん'" | |
| sleep 0.5 | |
| system "saykana '#{temp.to_i}ど'" | |
| if temp < threshold | |
| sleep 0.5 | |
| system 'saykana おからだにさわりますよ' | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
