diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2007-09-14 21:56:17 +0000 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2007-09-14 21:56:17 +0000 |
commit | 701697f569c50f8cfadd151bffdf2284c4caeda2 (patch) | |
tree | 850cae745326146dd4ec518ee5e5b14ff7540dac /data/rbot/plugins | |
parent | 5d27f65e540393ddcf00faed2bf514fe5c6630d8 (diff) |
twitter plugin: display time elapsed instead of date in status
Diffstat (limited to 'data/rbot/plugins')
-rw-r--r-- | data/rbot/plugins/twitter.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/data/rbot/plugins/twitter.rb b/data/rbot/plugins/twitter.rb index 39f43b80..530608ae 100644 --- a/data/rbot/plugins/twitter.rb +++ b/data/rbot/plugins/twitter.rb @@ -54,7 +54,12 @@ class TwitterPlugin < Plugin begin rex = REXML::Document.new(response) rex.root.elements.each("status") { |st| - msg = st.elements['text'].to_s + " (#{st.elements['created_at'].to_s} via #{st.elements['source'].to_s})" + month, day, hour, min, sec, year = st.elements['created_at'].text.match(/\w+ (\w+) (\d+) (\d+):(\d+):(\d+) \S+ (\d+)/)[1..6] + debug [year, month, day, hour, min, sec].inspect + time = Time.local(year.to_i, month, day.to_i, hour.to_i, min.to_i, sec.to_i) + now = Time.now + delta = now - time + msg = st.elements['text'].to_s + " (#{Utils.secs_to_string(delta.to_i)} ago via #{st.elements['source'].to_s})" texts << Utils.decode_html_entities(msg).ircify_html } rescue |