Skip to content

Commit

Permalink
10 mins
Browse files Browse the repository at this point in the history
  • Loading branch information
seki committed Jun 5, 2011
1 parent a05fc91 commit 119701d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion sample/copocopo.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
require 'drip_tw'
require 'my_drip'
require 'date'
require 'pp'

def dig(root, *keys)
Expand All @@ -27,6 +28,12 @@ def extract(str)
ary
end

def created_at(event)
DateTime.parse(event['created_at']).to_time
rescue
Time.at(1)
end

def make_status(ary, name)
"@#{name} " + ary.collect { |s|
"#{s}#{s}#{s}"
Expand All @@ -38,9 +45,10 @@ def main_loop
@last, event = @drip.read_tag(@last, 'DripDemo Event', 1)[0]
ary = extract(event['text'] || '')
if ary.size > 0
next unless Time.now < created_at(event) + 6000
name = dig(event, 'user', 'screen_name')
tweet_id = event['id']
if ['m_seki', 'miwa719', 'vestige', 'mame'].include?(name)
if ['miwa719', 'hsbt', 'vestige', 'mame'].include?(name)
@app.update(make_status(ary, name), tweet_id)
end
@drip.write(@last, 'CopoCopo Footprint')
Expand Down

0 comments on commit 119701d

Please sign in to comment.