Page 1 of 1

Guidance needed on basic AdiumScripting

Posted: Mon Oct 09, 2006 6:33 pm
by miklophone
Hi. I'm having trouble creating a working Adium script, and I'd appreciate some help. I've looked inside other Adium scripts, and adapted the code for myself. I can create a script which substitutes without paramters, but my problem is that I cannot create a working script which takes arguments. My initial aim is to create a script which allows me to run terminal commands within Adium.

I've named it Shell.AdiumScripts.

Contents->Info.plist looks like this:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>CFBundleDevelopmentRegion</key>
	<string>English</string>
	<key>CFBundleGetInfoString</key>
	<string>shell v0.1</string>
	<key>CFBundleIdentifier</key>
	<string>com.adiumx.shell.scripts</string>
	<key>CFBundleInfoDictionaryVersion</key>
	<string>0.5</string>
	<key>CFBundleName</key>
	<string>shell</string>
	<key>CFBundlePackageType</key>
	<string>AdIM</string>
	<key>Scripts</key>
	<array>
		<dict>
			<key>File</key>
			<string>shell</string>
			<key>Keyword</key>
			<string>/shell</string>
			<key>Title</key>
			<string>shell</string>
		</dict>
	</array>
	<key>Set</key>
	<string>shell</string>
</dict>
</plist>
Inside Resources, I have a script called shell.scpt. It looks like this:

Code: Select all


on substitute(theMessage)
	set theResult to do shell script theMessage
	return theResult
end substitute

When I type /shell xxx in Adium, it just echoes back the argument, and it does this whatever I put into the Applescript. I assume the plist file is faulty. Can anyone help?

Posted: Mon Oct 09, 2006 7:21 pm
by evands
You need to enclose your parameters in curly braces, {}, like so:

Code: Select all

/shell{xxx}
(Adium should be automatically putting /shell{arg1} on the input line if you select your script from the menu.)

Re: Guidance needed on basic AdiumScripting

Posted: Tue Oct 10, 2006 1:59 am
by zaudragon
miklophone wrote:

Code: Select all

on substitute(theMessage)
	set theResult to do shell script theMessage
	return theResult
end substitute
You could make that even simpler:
miklophone wrote:

Code: Select all

on substitute(theMessage)
	return (do shell script theMessage)
end substitute

Posted: Tue Oct 10, 2006 2:05 am
by miklophone
Thanks for your help. That was exactly what I needed to know. If only I'd posted here sooner... ;-)