Skip to content

Instantly share code, notes, and snippets.

@simonista
Created November 12, 2012 17:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simonista/4060781 to your computer and use it in GitHub Desktop.
Save simonista/4060781 to your computer and use it in GitHub Desktop.
Some custom limescripts
# remove the timestamp that bip inserts in a backlog message and set the time
# of the span element that limechat uses
bind 'line', (line) ->
# see if out message matches 'hh:mm:ss>'
$line = $(line)
html = $line.html()
regex = /(\d{2}:\d{2}):\d{2}>/
matches = html.match regex
return unless matches
# remove that timestamp from the message
html = html.replace regex, ""
$line.html html
# and add hh:mm to the .time span
time = $ "<span/>",
class: "time"
time.append matches[1]
$line.find(".time").replaceWith(time)
# put these in /limescripts/lib as well
# fail.png => http://cl.ly/image/183e0Z3L181f
# pass.png => http://cl.ly/image/233w153f3o2C
bind 'line', (line) ->
# see if out message matches:
# gilfus: ● .* Build (Succeeded|FAILED) in x mins ● name ● git status msg ● https://hudson.instructure.com/job/canvas-lms/7283/
message = $(line).find '.message'
regex = /●\s*([\w-]+) Build (Succeeded|FAILED) \w+:(\d+)\s*(?:in (\d+) mins)?\s*●\s*(\w+)\s*●\s*(.+)\s*●\s*(https:.*)\s*●/
matches = message.text().match regex
return unless matches
idx = 1 # 0 is the whole thing
buildType = matches[idx++]
success = matches[idx++]
patchset = matches[idx++]
time = matches[idx++]
user = matches[idx++]
gitMsg = matches[idx++].trim()
hudsonURL = matches[idx++].trim()
icon = if success == "Succeeded" then "pass.png" else "fail.png"
message.html ""
image = $ "<img/>",
src: "file:///Users/simonista/Library/Application Support/LimeChat/Themes/limescripts/lib/#{icon}"
class: "build-icon"
image.appendTo message
build = $ "<span/>"
build.append " #{user} ➜ "
build.appendTo message
hudson = $ "<a/>",
href: hudsonURL
hudson.append gitMsg
hudson.appendTo message
whichBuild = $ "<span/>"
whichBuild.append " [#{buildType}:#{patchset}]"
whichBuild.appendTo message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment