Scripting Adium

An instant messenger which can connect to AIM, GTalk, Jabber, ICQ, and more.
Post Reply
mageman160
Harmless
Posts: 6
Joined: Sat Jan 28, 2006 12:07 am

Scripting Adium

Post 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
User avatar
evands
Cocoaforge Admin
Posts: 3152
Joined: Thu Dec 02, 2004 10:55 pm
Location: Decatur, GA
Contact:

Post 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.
The duck still burns.
--
My company: Saltatory Software. Check it out :)
mageman160
Harmless
Posts: 6
Joined: Sat Jan 28, 2006 12:07 am

Thanks

Post by mageman160 »

Thanks muchly!
Post Reply