Reputation: 6413
I'd love to send my Adium contacts messages from the command line. The syntax should look like echo test | im <contact>
. I've taken and modified this script to do what I want, but it's a little old and I'm trying to modernize it. So far, I've got this working (I only changed the applescript, here.)
set stdinText to do shell script "echo \"\$MESSAGE\"" without altering line endings
tell application "Adium"
set user to get contact "$BUDDY"
if not (exists (chats whose contacts contains user)) then
if not (exists (first chat window)) then
tell account of user
set new_chat to make new chat with contacts {user} with new chat window
end tell
else
set existing_window to first chat window
tell account of user
set new_chat to make new chat with contacts {user} in window existing_window
end tell
end if
else
set new_chat to first chat whose contacts contains user
end if
send new_chat message stdinText
end tell
Works well, except that the chat message is sent twice. Is this a bug in Adium or am I doing something wrong in applescript?
Upvotes: 0
Views: 880
Reputation: 26
I also ran up against this bug, where Adium was sending the chat message multiple times.
It's caused by more than one running background process named AdiumApplescriptRunner. Apparently only one of these processes is supposed to be running at any given time, but sometimes more than one starts up, and when this happens you get a duplicate chat message sent for each extra AdiumApplescriptRunner process.
My work around was to create a cron task, that runs every minute, and executes this bash command:
ps -aef | grep -v grep | grep 'AdiumApplescriptRunner' | awk '{print $2}' | awk 'NR == 2,/c/' | xargs -I %s kill -9 %s
This command makes sure only one process named AdiumApplescriptRunner is running, and kills any but the one that Adium created.
Upvotes: 1