- rex = REXML::Document.new(response)
- rex.root.elements.each("status") { |st|
- # 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)
- time = Time.parse(st.elements['created_at'].text)
- now = Time.now
- # Sometimes, time can be in the future; invert the relation in this case
- delta = ((time > now) ? time - now : now - time)
- msg = st.elements['text'].to_s + " (#{Utils.secs_to_string(delta.to_i)} ago via #{st.elements['source'].to_s})"
- author = ""
- if friends
- author = Utils.decode_html_entities(st.elements['user'].elements['name'].text) + ": " rescue ""
+ tweets = JSON.parse(response)
+ if tweets.class == Array
+ tweets.each do |tweet|
+ time = Time.parse(tweet['created_at'])
+ now = Time.now
+ # Sometimes, time can be in the future; invert the relation in this case
+ delta = ((time > now) ? time - now : now - time)
+ msg = tweet['text'] + " (#{Utils.secs_to_string(delta.to_i)} ago via #{tweet['source'].to_s})"
+ author = ""
+ if type
+ author = tweet['user']['name'] + ": " rescue ""
+ end
+ texts << author+Utils.decode_html_entities(msg).ircify_html