Module: Inko
- Extended by:
- Inko
- Included in:
- Inko
- Defined in:
- lib/inko.rb,
lib/inko/config.rb,
lib/inko/version.rb
Defined Under Namespace
Modules: Config
Constant Summary collapse
- VERSION =
"0.0.5"
Instance Method Summary collapse
- #filter?(status) ⇒ Boolean
-
#pronunciationize(status) ⇒ Object
modify screen_name and text to make them easy to pronounce _,! cf d.hatena.ne.jp/nacookan/20081220/1229745342.
- #run ⇒ Object
Instance Method Details
#filter?(status) ⇒ Boolean
11 12 13 |
# File 'lib/inko.rb', line 11 def filter? status !status.user || !status.text end |
#pronunciationize(status) ⇒ Object
modify screen_name and text to make them easy to pronounce _,! cf d.hatena.ne.jp/nacookan/20081220/1229745342
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/inko.rb', line 18 def pronunciationize status status.user.screen_name = status.user.screen_name.gsub(/_/, ' ') .gsub(/([a-zA-Z]+|[0-9]+)/){$1 + ' '} .gsub(/@/,'@. ') status.text = Shellwords::escape( status.text.split(/\n/).join(" ") .gsub(/!/,'!') .gsub(/w+/, ' 笑い ') .gsub(/http:\/\/[^\s]+/, ' URL 略 ') ) status end |
#run ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/inko.rb', line 31 def run begin UserStream.configure do |config| config.consumer_key = Config::ConsumerKey config.consumer_secret = Config::ConsumerSecret config.oauth_token = Config::OAuthToken config.oauth_token_secret = Config::OAuthSecret end rescue UserStream::Unauthorized => e STDERR.puts "contents of #{Config::ConfigFileName} is invalid!" raise e end UserStream::client.user do |status| unless filter? status status = pronunciationize status # puts "#{status.user.screen_name}: " # puts status.text `say -v #{Config::VoiceActor} #{status.user.screen_name} さんのツイート}` `say -v #{Config::VoiceActor} #{status.text}` end end end |