Created
April 1, 2010 04:34
-
-
Save atr000/351358 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
property scriptInitialPath : null | |
property loadedScriptName : "" | |
using terms from application "Colloquy" | |
on process incoming chat message msg in msgChatRoom | |
set frontRoom to description of active panel of front window | |
-- to convert a chat room's name to a chat room's description, here's what | |
-- I needed to do. Depending on how you connect, you may need to change | |
-- this a little. You'll know that you do need to change this if you keep | |
-- getting JIRA titles when your "front room" fills with unexpected JIRA | |
-- titles! (Then again, perhaps you'd like to know what's being talked | |
-- about and don't mind too much ...) | |
set msgChatRoomName to "Chat Room #" & name of msgChatRoom & " (127.0.0.1)" | |
-- check that the message we're processing is on our front panel | |
if msgChatRoomName is equal to frontRoom then | |
try | |
-- the message is a class - not the text, so we have to extract it | |
set thisMessage to HTML of msg | |
-- I have a shell script that does the pattern matching. There is | |
-- an extension to AppleScript that allows for this sort of work, | |
-- but the Forge community is good with a little Unix and probably | |
-- don't mind installing a script. | |
-- The quotes are necessary as sentences often have spaces ... | |
set jiraRef to do shell script "~/jiraRef.pl \"" & thisMessage & "\"" | |
-- call our seperate method to handle this | |
getJira(jiraRef) | |
on error | |
-- annoyingly, AppleScript often fails silently - and I've not | |
-- actually seen this run. | |
tell active panel of front window | |
add event message "error caught: " & errorMessage | |
end tell | |
end try | |
end if | |
end process incoming chat message | |
on process user command cmd with args for chatRoom | |
-- This may be useful as it allows me to check jjira refs | |
if cmd is equal to "jira" then | |
set jiraLine to args | |
set jiraRef to do shell script "~/jiraRef.pl \"" & args & "\"" | |
getJira(jiraRef) | |
end if | |
end process user command | |
-- I'm sure that in the future I'll add extra parameters to this so | |
-- that I can get things like when it was last updated, the status | |
-- and who perhaps last commented. But for now it's simple. | |
to getJira(jiraRef) | |
if jiraRef is not equal to "" then | |
-- this next ommand is long - I might write this into a seperate | |
-- script. But again, for now it works and allows me flexibility | |
set jiraTitle to do shell script "curl --cert \ | |
--pass -k https://JIRA-SERVER/browse/" & jiraRef & \ | |
" | grep '<title>' | sed 's/title/em/g' | sed 's/ - BBC JIRA//'" | |
tell active panel of front window | |
--add event message jiraTitle with name "jiraTitle" | |
add event message "JIRA " & jiraTitle | |
--add event message " | |
& "\">" & jiraTitle & "" with name "jiraTitle" | |
end tell | |
end if | |
end getJira | |
on load from scriptPath | |
set scriptAlias to (POSIX file scriptPath) as alias | |
set loadedScriptName to (name of (info for scriptAlias)) | |
set msg to (loadedScriptName & " Loaded /jira | |
") as string | |
set evt to (loadedScriptName & "loaded") as string | |
tell active panel of front window | |
add event message msg with name evt | |
end tell | |
end load | |
on unload | |
set msg to (loadedScriptName & " Unloaded") as string | |
set evt to (loadedScriptName & "unloaded") as string | |
tell active panel of front window | |
add event message msg with name evt | |
end tell | |
set loadedScriptName to "" | |
end unload | |
end using terms from |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment