diff --git a/facebook_stream/lib_facebook_stream.rb b/facebook_stream/lib_facebook_stream.rb index ace5d69..3fb6d79 100644 --- a/facebook_stream/lib_facebook_stream.rb +++ b/facebook_stream/lib_facebook_stream.rb @@ -7,11 +7,12 @@ require 'json' #'CAAD8cd4tMVkBAO3sh2DrzwZCDfeQq9ZAvTz7Jz24ZC26KtMfBoljqaXhD2vBV1zpP0bjrpxXUBzJvKKcFzOm6rMG9Sok7iNVUaxt5iwr7dfMqCvHpMboKpqrqgeLrfCH5ITVTAdezA6ZBSr9iOJrqyCSOYfui0zTmbXJ3FqtshwNRrRy4NPH' # BACKUP TOKEN 'CAAEhsewl0ZAcBAHhipXszZCURSwWLmgvceDbs9mB5baJdLriFxYMEzywmF2fvZBuThuA2Mm7QF8wPd3E6R5pVqVEnC2VhcBb4VrfAnkZC73ZC5g1NRUnKZCB2e6CaRiUBDatR2nf505PeKp7Aj5XxvTdfSqdZCsXxQFYZApPNSUUgkUWm6HwL4rp21MRJXb612sZD' -def facebook_comments(hub_id, author_id, page_id="participabr", pooling_time=5, token='CAAD8cd4tMVkBAO3sh2DrzwZCDfeQq9ZAvTz7Jz24ZC26KtMfBoljqaXhD2vBV1zpP0bjrpxXUBzJvKKcFzOm6rMG9Sok7iNVUaxt5iwr7dfMqCvHpMboKpqrqgeLrfCH5ITVTAdezA6ZBSr9iOJrqyCSOYfui0zTmbXJ3FqtshwNRrRy4NPH') +def facebook_comments(hub, author_id, page_id="participabr", pooling_time=5, token='CAAD8cd4tMVkBAO3sh2DrzwZCDfeQq9ZAvTz7Jz24ZC26KtMfBoljqaXhD2vBV1zpP0bjrpxXUBzJvKKcFzOm6rMG9Sok7iNVUaxt5iwr7dfMqCvHpMboKpqrqgeLrfCH5ITVTAdezA6ZBSr9iOJrqyCSOYfui0zTmbXJ3FqtshwNRrRy4NPH') + + #raise hub.id.inspect @graph = Koala::Facebook::API.new(token) initialComments = [] extractedComments = [] - newComments = [] firstTime = true while true feed = @graph.get_connections(page_id, "posts") @@ -24,7 +25,7 @@ def facebook_comments(hub_id, author_id, page_id="participabr", pooling_time=5, } array.each{ |comments| comments.each{|comment| - extractedComments.push("#{comment['from']['name']} " + _("said:") + " : #{comment['message']}") + extractedComments.push("#{comment['from']['name']} " + _("said") + ": #{comment['message']}") } } extractedComments = extractedComments.uniq @@ -34,12 +35,12 @@ def facebook_comments(hub_id, author_id, page_id="participabr", pooling_time=5, end newComments = extractedComments - initialComments newComments = newComments.uniq - initialCommentsinitialComments += newComments + initialComments += newComments initialComments = initialComments.uniq newComments.each{|comment| puts comment noosferoComment = Comment.new - noosferoComment.source_id = hub_id + noosferoComment.source_id = hub.id noosferoComment.body = comment noosferoComment.author_id = author_id noosferoComment.save! diff --git a/lib/community_hub_plugin/hub.rb b/lib/community_hub_plugin/hub.rb index 4faf285..3deb73a 100644 --- a/lib/community_hub_plugin/hub.rb +++ b/lib/community_hub_plugin/hub.rb @@ -33,24 +33,24 @@ class CommunityHubPlugin::Hub < Folder true end - def self.twitter_service(page, action) - author_id = 54 - if action==:start - thread = Thread.new { - Twurl::Stream.run(page, author_id,'torrent', File.dirname(__FILE__) + '/../../tweeter_stream/config/twurlrc') - } unless@@twitter_thread_started - @@twitter_thread_started = true - end + def self.twitter_service(hub, action) +# author_id = 54 +# if action==:start +# thread = Thread.new { +# Twurl::Stream.run(hub, author_id,'torrent', File.dirname(__FILE__) + '/../../tweeter_stream/config/twurlrc') +# } unless@@twitter_thread_started +# @@twitter_thread_started = true +# end end - def self.facebook_service(page, action) + def self.facebook_service(hub, action) author_id = 54 page_id="mundoreagindo" if action==:start - thread = Thread.new { - #facebook_comments(page, author_id, page_id, pooling_time=5, token='CAAD8cd4tMVkBAO3sh2DrzwZCDfeQq9ZAvTz7Jz24ZC26KtMfBoljqaXhD2vBV1zpP0bjrpxXUBzJvKKcFzOm6rMG9Sok7iNVUaxt5iwr7dfMqCvHpMboKpqrqgeLrfCH5ITVTAdezA6ZBSr9iOJrqyCSOYfui0zTmbXJ3FqtshwNRrRy4NPH') - facebook_comments(page, author_id, page_id) - } unless@@facebook_thread_started + #facebook_comments(page, author_id, page_id, pooling_time=5, token='CAAD8cd4tMVkBAO3sh2DrzwZCDfeQq9ZAvTz7Jz24ZC26KtMfBoljqaXhD2vBV1zpP0bjrpxXUBzJvKKcFzOm6rMG9Sok7iNVUaxt5iwr7dfMqCvHpMboKpqrqgeLrfCH5ITVTAdezA6ZBSr9iOJrqyCSOYfui0zTmbXJ3FqtshwNRrRy4NPH') + thread = Thread.new { + facebook_comments(hub, author_id, page_id) + } unless@@facebook_thread_started @@facebook_thread_started = true end end diff --git a/tweeter_stream/lib/twurl/request_controller.rb b/tweeter_stream/lib/twurl/request_controller.rb index d6b82a4..416cad9 100755 --- a/tweeter_stream/lib/twurl/request_controller.rb +++ b/tweeter_stream/lib/twurl/request_controller.rb @@ -20,7 +20,7 @@ module Twurl begin parsed = JSON.parse(chunk) ic = Iconv.new('UTF-8//IGNORE', 'UTF-8') - comment_text = ic.iconv("@#{parsed["user"]["name"]} " + _('said:') + " #{parsed["text"]}" + ' ')[0..-2] + comment_text = ic.iconv("@#{parsed["user"]["name"]} " + _('said') + ": #{parsed["text"]}" + ' ')[0..-2] print "#{comment_text}\n" comment = Comment.new comment.source_id = Stream.page.id -- libgit2 0.21.2