Page 1 of 1

Scripting Adium

Posted: Mon Mar 27, 2006 2:36 am
by mageman160
I'm trying to write a script which will return a html encoded link. However, it just returns the html and sends that. I looked in the dictionary and i know i should be using send (in conjunction with message, which allows HTML encoded messages to be sent). However... im not sure how to say 'send to the current chat'
can anyone help?

Current code:

Code: Select all

on substitute(card)
	set theResult to {"http://gatherer.wizards.com/gathererlookup.asp?name=" & encodept1(card) & "&x=0&y=0"}
	tell application "Adium"
		display dialog theResult buttons {"Cancel", "Ok"}
	end tell
	set theLink to "<a href='" & theResult & "'>" & card & "</a>"
	tell application "Adium"
		--send this message theLink
	end tell
	return theLink
end substitute

on encodept1(str)
	set encoded to ""
	repeat with i in str
		set j to i as text
		set encoded to {encoded & encode(j)}
	end repeat
	return encoded
end encodept1

on encode(chara)
	if chara = " " then
		return "%20"
	end if
	if chara = "'" then
		return "%27"
	end if
	if chara ? " " and chara ? "'" then
		return chara
	end if
end encode
--testing...
substitute("fghe gfio'ijf")
--encode("fghe gfio'ijf")
Thanks

Posted: Mon Mar 27, 2006 3:07 am
by evands
You just return what you want the substitution to be; you don't need to do send. Enclose your HTML return with <HTML> and </HTML> to tell adium to parse it as such.

Thanks

Posted: Mon Mar 27, 2006 8:27 pm
by mageman160
Thanks muchly!