Created
January 15, 2013 12:11
-
-
Save no6v/4538184 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
inspired by https://gist.github.com/4164516 :).