Page 1 of 1
Need help with script for Adium...
Posted: Wed Feb 02, 2005 12:25 am
by falconbrad
OK, so I'm working on a script that I would like to be able to invoke every time someone signs on or off. I'm not exactly sure how one would go about that or if it's even possible, since requesting a user's status can I guess technically only be done once unless it's in a loop, but yeah, I was wondering if there's a way to do it.
To be honest, I just started coding with AppleScript last night and I'm still trying to get used to it. So thanks in advance for your help!
Posted: Wed Feb 02, 2005 12:44 am
by zaudragon
You can tell people to add it to the alerts in Adium
Posted: Wed Feb 02, 2005 12:45 am
by BlueRevolution
would it work that way? I was thinking you could write a stay-open script that polls Adium to check when contacts sign on/off. check out the dictionary for Adium... in theory you could use
Code: Select all
tell application "Adium"
return contacts of accounts
end tell
but I'm not sure if all of the properties you'd need are available there.
have fun with applescript, I'm available if you need a hand with anything.
Posted: Wed Feb 02, 2005 3:37 am
by falconbrad
Wow, thanks a lot for your help. I've mucked around with the Adium commands, but I can't seem to get them to work out the way I want to... Oh well. I completely forgot about the alerts, since I never use them. You can also add the alerts to an entire group, so that works well.
Now I need help with some XML parsing.
Specifically, I want the ability for the script to place a link in it's place, and when the link is clicked, I want the link to be reaplaced with a sentence composed in part of text from an XML file. I've been using curl in a shell script to grab the page, and I figured I would just use curl | grep to find my text, but I can't seem to get it to work, and I'm pretty sure the problem is escape characters. Here's what the script editor returns when I grab the page with curl:
<response value=\"0\" type=\"OK\">Data inserted OK</response>
<color value=\"5\">dark yellow</color>
I want to be able to pull the color ('dark yellow' in this case) into a string which is displayed once the link is clicked, but I'm confused because the quote escapes the shell script...
Posted: Wed Feb 02, 2005 4:02 am
by BlueRevolution
you mean the way you end up with \" instead of " ? that's just the way Script Editor displays strings - they'll appear normally in Adium and even Script Editor treats them as single characters.
[edit: fixed dumb typo]
Posted: Wed Feb 02, 2005 7:37 am
by falconbrad
OK, I think I figured that one out. One last question, then I'll stop bugging you guys. I can't seem to figure out the sed command format for printing the text between two characters (specifically a right and left bracket)...
Posted: Wed Feb 02, 2005 9:00 am
by BlueRevolution
sed is one thing I don't really understand. if it helps, I have this code courtesy of Jack Gill that I use in my Adium Googlismifier script:
Code: Select all
set fixedString to (do shell script "echo \"" & toFix & "\" | sed -e 's/[^a-zA-Z ]//g' -e 's/ /+/g'")
[all one line, just wrapped]
I don't know if that helps.
Posted: Wed Feb 02, 2005 9:50 am
by falconbrad
Yeah, I'm definitely not a whiz at shell scripting. I've read through the man pages for sed, but I still don't seem to be able to figure out how to do what I want. Maybe sed is the wrong command, I dunno. I guess I could use awk {print}, but that seems to give me even less flexibility. I guess I'll keep trying.
I have posted a version of my script in the Xtras already. It's called AmbientAdium, and when invoked with an
Ambient Orb ID number as its argument, randomly changes the color of the orb. Now I'm just trying to expand on that, so it changes animations when users come online or offline, etc.
If you guys have any suggestions (does anyone else besides me own an Ambient Orb?), let me know.
The current codebase is replicated below (it's pretty damn simple).
Code: Select all
on substitute(IDString)
set coloramb to (random number from 1 to 35)
set stemURL to "www.myambient.com:8080/java/my_devices/submitdata.jsp?"
set devID to "devID=" & IDString
set colorarg to "&color=" & coloramb
set anim to "&anim=0"
set finishstring to "Ambient Orb color successfully changed!"
set ambURL to stemURL & devID & colorarg & anim
do shell script "curl '" & ambURL & "'"
return finishstring
end substitute
Posted: Wed Feb 02, 2005 3:11 pm
by BlueRevolution
I'd have one, but they're too darn expensive. all the best with scripting for it though!

Posted: Thu Feb 17, 2005 10:15 pm
by falconbrad
So I'm working on this again, and once again I need help parsing the XML file that is returned by the script I have written. I've tried using shell scripting to weed out what I want, but I can't seem to isolate the color output (which is ultimately what I want to get my hands on and return). I really don't want to have to use the XML parsing AppleScipt tools because it is (1) so big and (2) I don't know how to incorporate it into this project and disseminate it when I want to release the next version. Any thoughts on how to parse the info I'm getting? The returned XML code from the website looks like:
Code: Select all
<?xml version="1.0"?>
<insert_custom_data>
<device devID="RBD-6AA-AC9">
<response value="0" type="OK">Data inserted OK</response>
<color value="0">red</color>
<anim value="8">cresendo</anim>
<comment>Insert comment here</comment>
<sourceIP>128.125.5.70</sourceIP>
<submittedAt value="20050217174835">Feb 17, 2005 5:48:35 PM</submittedAt>
<maxNextUpdate value="20050217180000">Feb 17, 2005 6:00:00 PM</maxNextUpdate>
</device>
</insert_custom_data>
I want to get the color and animation style from the webiste and then be able to take each of those as a string. Again, any help would be greatly appreciated.