Created
July 28, 2012 07:33
-
-
Save baopham/3192256 to your computer and use it in GitHub Desktop.
Quicksilver + Messages
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
| using terms from application "Quicksilver" | |
| on process text im_text | |
| set im_command to parseCommand(im_text) | |
| runCommand(contact of im_command, message of im_command) | |
| end process text | |
| end using terms from | |
| on parseCommand(im_text) | |
| repeat with im_delimiter_position from 1 to (length of im_text) | |
| set ch to character im_delimiter_position of im_text | |
| if ch = ":" then exit repeat | |
| end repeat | |
| set im_contact to characters 1 thru (im_delimiter_position - 1) of im_text as string | |
| set im_message to characters (im_delimiter_position + 2) thru (length of im_text) of im_text as string | |
| return {contact:im_contact, message:im_message} | |
| end parseCommand | |
| on runCommand(im_contact, im_message) | |
| using terms from application "Messages" | |
| sendMessage(im_contact, im_message) | |
| end using terms from | |
| end runCommand | |
| on sendMessage(im_contact, im_message) | |
| tell application "Messages" | |
| repeat with my_buddy in buddies | |
| if im_contact is in full name of my_buddy then | |
| send im_message to my_buddy | |
| return | |
| end if | |
| end repeat | |
| end tell | |
| -- Growl alert if no buddy is found | |
| growlMessage("Error Notification", "User not found: " & im_contact) | |
| end sendMessage | |
| on growlMessage(growltype, str) | |
| tell application id "com.Growl.GrowlHelperApp" | |
| -- Make a list of all the notification types | |
| -- that this script will ever send: | |
| set the allNotificationsList to ¬ | |
| {"General Notification", "Error Notification"} | |
| -- Make a list of the notifications | |
| -- that will be enabled by default. | |
| -- Those not enabled by default can be enabled later | |
| -- in the 'Applications' tab of the Growl preferences. | |
| set the enabledNotificationsList to ¬ | |
| {"General Notification", "Error Notification"} | |
| -- Register our script with growl. | |
| -- You can optionally (as here) set a default icon | |
| -- for this script's notifications. | |
| register as application ¬ | |
| "Quicksilver Messages" all notifications allNotificationsList ¬ | |
| default notifications enabledNotificationsList ¬ | |
| icon of application "Messages" | |
| -- Send a Notification... | |
| notify with name ¬ | |
| growltype title ¬ | |
| "Error" description ¬ | |
| str application name "Quicksilver Messages" | |
| end tell | |
| end growlMessage |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment