Created
March 9, 2012 10:35
-
-
Save ohac/2006011 to your computer and use it in GitHub Desktop.
simple short output plugin for earthquake and notmailto
This file contains 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
# encoding: UTF-8 | |
require 'stringio' | |
Earthquake.init do | |
output :tweet do |item| | |
next unless item["text"] | |
info = [] | |
if item["in_reply_to_status_id"] | |
info << "to #{id2var(item["in_reply_to_status_id"])}" | |
elsif item["retweeted_status"] | |
info << "of #{id2var(item["retweeted_status"]["id"])}" | |
end | |
id = id2var(item["id"]) | |
text = (item["retweeted_status"] && item["truncated"] ? "RT @#{item["retweeted_status"]["user"]["screen_name"]}: #{item["retweeted_status"]["text"]}" : item["text"]).u | |
text.gsub!(/([☎´ω`—■■□◆◇⊂⊃※“”☆★…])/, '\1 ') | |
text.gsub!(/\s+/, ' ') | |
text = text.coloring(/@[0-9A-Za-z_]+/) { |i| color_of(i) } | |
text = text.coloring(/(^#[^\s]+)|(\s+#[^\s]+)/) { |i| color_of(i) } | |
text.gsub!(/https{0,1}:\/\/t\.co\/(\w+)/, '\1@t.co') | |
text = text.coloring(/[0-9A-Za-z\-.]+@t\.co/, :url) | |
mark = item["_mark"] || "" | |
screen_name = item["user"]["screen_name"] | |
status = [ | |
"#{mark}" + "#{id}".c(:info), | |
"#{screen_name.c(color_of(screen_name))}", | |
"#{text}", | |
(item["user"]["protected"] ? "P".c(:notice) : nil), | |
info.join(' - ').c(:info) | |
].compact.join(" ") | |
puts status | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Replace http://t.co/ABC to ABC@t.co
Very short.