Skip to content

Instantly share code, notes, and snippets.

@slucero
Created October 11, 2012 00:47
Show Gist options
  • Save slucero/3869470 to your computer and use it in GitHub Desktop.
Save slucero/3869470 to your computer and use it in GitHub Desktop.
Alfred Extension: Tabbed Adium Chat
on alfred_script(q)
set theString to "" & q
set theMessage to theString
#get the name portion of the string
set AppleScript's text item delimiters to {":"}
set chatParts to (every text item in theString) as list
set theName to item 1 of chatParts
#get the message portion of the string
-- 0 = beginning, 1 = end, 2 = both
set AppleScript's text item delimiters to {""}
set x to the length of the (theName & ":")
-- TRIM BEGINNING
repeat while theMessage begins with the (theName & ":")
try
set theMessage to characters (x + 1) thru -1 of theMessage as string
on error
-- the text contains nothing but the trim characters
return ""
end try
end repeat
#end of get the message portion of the string
tell application "System Events"
set theCount to count (every process whose name contains "Adium")
end tell
if theCount = 0 then
tell application "Adium"
activate
end tell
delay 5
end if
tell application "Adium"
try
set theContact to get name of first contact whose display name contains theName
if length of theContact > 0 then
tell application "Adium" to set theAccount to the account of the contact theContact
try
tell application "Adium" to set chatWindow to front chat window
tell theAccount to set newChat to make new chat with contacts {contact theContact} at after last chat of chatWindow
tell newChat to become active
on error
tell theAccount to set newChat to make new chat with contacts {contact theContact} with new chat window
end try
if length of theMessage is greater than 0 and theName is not equal to theMessage then
tell application "Adium" to send newChat message theMessage
end if
end if
on error
display dialog "Sorry. I was unable to find the Adium contact with '" & theName & "' in it's display name and launch the chat."
end try
end tell
end alfred_script
@slucero
Copy link
Author

slucero commented Oct 11, 2012

This is an altered version of the Adium Chat extension for Alfred by urisdacosta. It has been reworked to open new chat conversations as a tab if there are existing chat windows open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment