Skip to content

Instantly share code, notes, and snippets.

@no6v
Created January 15, 2013 12:11
Show Gist options
  • Save no6v/4538184 to your computer and use it in GitHub Desktop.
Save no6v/4538184 to your computer and use it in GitHub Desktop.
Earthquake.once do
class ::TwitterOAuth::Client
def related_results(id)
get("/related_results/show/#{id}.json")
end
end
end
Earthquake.init do
command :conversation do |m|
id = m[1]
case related_results = twitter.related_results(id).presence
when Hash
puts related_results["error"].c(:notice) if $VERBOSE
when Array
conversation = [twitter.status(id)]
results = related_results[0]["results"].group_by{|result| result["annotations"]["ConversationRole"]}
values = ->(role){(results[role] || []).map{|result| result["value"]}}
conversation.unshift(*values["Ancestor"]).push(*values["Descendant"])
puts_items conversation.each_with_index{|tweet, index|
tweet["_mark"] = config[:thread_indent] * index
}.reverse
next
end
input(":thread #{id}")
end
end
@no6v
Copy link
Author

no6v commented Jan 15, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment