Created
January 7, 2014 01:58
-
-
Save prenagha/8293517 to your computer and use it in GitHub Desktop.
Launchbar script to allow you to send an Adium chat message directly from within Launchbar Install: put this script in ~/Library/Application Support/Adium/Actions Invoke Launchbar type "Chat" to find this action, then space to trigger text entry, then "<contact partial name><space>chat message"
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
-- used via launchbar | |
-- im_text: contact_partial_name message | |
handle_string("foobar testing") | |
on handle_string(im_text) | |
-- start adium if its not running | |
if application "Adium" is not running then | |
tell application "Adium" to activate | |
-- wait a few seconds to let the accounts login | |
delay 5 | |
end if | |
-- if not running now then error | |
if application "Adium" is not running then | |
tell application "LaunchBar" to display in large type "! Unable to start Adium !" with sound "Frog" | |
return | |
end if | |
-- grab the partial contact name | |
repeat with im_delimiter_position from 1 to (length of im_text) | |
if character im_delimiter_position of im_text = " " then exit repeat | |
end repeat | |
set im_contact_name to characters 1 thru (im_delimiter_position - 1) of im_text as string | |
-- if message specified then grab it | |
if im_delimiter_position is not equal to length of im_text then | |
set im_message to characters (im_delimiter_position + 1) thru (length of im_text) of im_text as string | |
end if | |
tell application "Adium" | |
-- get user | |
try -- first try to get online contact | |
set user to first contact whose status type is not offline and (display name contains im_contact_name or name contains im_contact_name) | |
on error | |
-- if not possible, get offline contact | |
try | |
set user to first contact whose display name contains im_contact_name or name contains im_contact_name | |
set un to display name of user | |
tell application "LaunchBar" to display in large type "! User " & un & " is offline !" with sound "Frog" | |
return | |
on error | |
tell application "LaunchBar" to display in large type "! Unable to find user " & im_contact_name & " !" with sound "Frog" | |
return | |
end try | |
end try | |
if not (exists (chats whose contacts is user)) then | |
if not (exists (first chat window)) then | |
tell account of user to (make new chat with contacts {user} with new chat window) | |
else | |
set existing_window to first chat window | |
tell account of user to (make new chat with contacts {user} in window existing_window) | |
end if | |
end if | |
if im_delimiter_position is not equal to length of im_text then | |
-- send message | |
(send (first chat whose contacts contains user) message im_message) | |
end if | |
tell (first chat whose contacts contains user) to become active | |
tell application "LaunchBar" to hide | |
activate | |
end tell | |
return | |
end handle_string |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment