Skip to content

Commit

Permalink
Added colour to several sorts of output.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pistos committed Nov 30, 2009
1 parent 64e46d7 commit e27ca54
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions github-hook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def receive_data( data )
author = cdata[ 'author' ][ 'name' ]
message = cdata[ 'message' ].gsub( /\s+/, ' ' )[ 0..384 ]
url = zepto_url( cdata[ 'url' ] )
text = "[github] [\00303#{repo}\003] <\00307#{author}\003> #{message} #{url}"
text = "[\00300github\003] [\00303#{repo}\003] <\00307#{author}\003> #{message} #{url}"

if channels.nil? or channels.empty?
say "Unknown repo: '#{repo}'", '#mathetes'
Expand All @@ -108,7 +108,7 @@ def receive_data( data )
shas.each do |sha|
s[ sha ] = true
end
say "[github] [\00303#{repo}\003] #{commits.size} commits by: \00307#{authors.join( ', ' )}\003 #{first_url}", channel
say "[\00300github\003] [\00303#{repo}\003] #{commits.size} commits by: \00307#{authors.join( ', ' )}\003 #{first_url}", channel
end
end

Expand Down
2 changes: 1 addition & 1 deletion key-value-store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def initialize
end

def say( message, channel )
$reby.putserv "PRIVMSG #{channel} :[kv] #{message}"
$reby.putserv "PRIVMSG #{channel} :[\00300kv\003] #{message}"
end

def info( nick, userhost, handle, channel, args )
Expand Down
4 changes: 2 additions & 2 deletions reby-twitter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def say_tweet( tweet )
tweet_id = tweet.id.to_i
src = tweet.user.screen_name
text = clean_text( tweet.text )
alert = "[twitter] <#{src}> #{text}"
alert = "[\00300twitter\003] <#{src}> #{text}"
channels = CHANNELS[ src ] || [ 'Pistos' ]
channels.each do |channel|
if not @seen[ channel ].include?( tweet_id )
Expand All @@ -127,7 +127,7 @@ def say_search_tweet( tweet, channels = [ 'Pistos' ] )
tweet_id = tweet[ 'id' ].to_i
src = tweet[ 'from_user' ]
text = clean_text( tweet[ 'text' ] )
alert = "[twitter] <#{src}> #{text}"
alert = "[\00300twitter\003] <#{src}> #{text}"
channels.each do |channel|
if not @seen[ channel ].include?( tweet_id )
say alert, channel
Expand Down
8 changes: 4 additions & 4 deletions url-summary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def summarize_url( url, channel )
fetch url
end
rescue EOFError, ByteLimitExceededException
$reby.log "[URL] Byte limit reached reading #{url} (document reached #{@doc_text.length} bytes)"
$reby.log "[\00300URL\003] Byte limit reached reading #{url} (document reached #{@doc_text.length} bytes)"
end

doc = Nokogiri::HTML( @doc_text )
Expand Down Expand Up @@ -98,7 +98,7 @@ def summarize_url( url, channel )
summary = summary.strip.gsub( /\s+/, ' ' )
if summary.length > 10
summary = summary.split( /\n/ )[ 0 ]
say "[URL] #{summary[ 0...160 ]}#{summary.size > 159 ? '[...]' : ''}", channel
say "[\00300URL\003] #{summary[ 0...160 ]}#{summary.size > 159 ? '[...]' : ''}", channel
end
end
rescue Timeout::Error
Expand Down Expand Up @@ -137,7 +137,7 @@ def sawPRIVMSG( from, keyword, text )
json = http.read
tweet = JSON.parse( json )
escaped_text = CGI.unescapeHTML( tweet[ 'text' ].gsub( '&quot;', '"' ).gsub( '&amp;', '&' ) ).gsub( /\s/, ' ' )
say "[twitter] <#{tweet[ 'user' ][ 'screen_name' ]}> #{escaped_text}", channel
say "[\00300twitter\003] <#{tweet[ 'user' ][ 'screen_name' ]}> #{escaped_text}", channel
end
when %r{(http://github.com/.+?/(.+?)/commit/.+)}
doc = Nokogiri::HTML( open( $1 ) )
Expand All @@ -151,7 +151,7 @@ def sawPRIVMSG( from, keyword, text )
number_files[:added] = doc.css( 'div#toc ul li.added' ).size
number_files[:removed] = doc.css( 'div#toc ul li.removed' ).size

s = "[github] [#{project}] <#{author}> #{commit_message} {+#{number_files[ :added ]}/-#{number_files[ :removed ]}/*#{number_files[ :modified ]}}"
s = "[\00300github\003] [#{project}] <#{author}> #{commit_message} {+#{number_files[ :added ]}/-#{number_files[ :removed ]}/*#{number_files[ :modified ]}}"
say s, channel
when %r|(http://(?:[0-9a-zA-Z-]+\.)+[a-zA-Z]+(?:/[0-9a-zA-Z#{"\303\244-\303\256"}~!@#%&./?=_+-]*)?)|u
summarize_url $1, channel
Expand Down

0 comments on commit e27ca54

Please sign in to comment.