AAIR (Aaon's AIO iChat Remote)

Update News:
Ok, I may have fibbed when I said I would wait a period of time before releasing v2.0 Beta! Trust me I had all intentions of holding off, but what I wanted to do came to me in a flash and I had to write it down. To my surprise, it worked from the get go.

Changes:
v2.0 Beta

There has been no real changes to the stability or flow of things. Plugins are now auto loaded into AAIR. No need to edit the AAIR script to add a plugin. Simply create a plugin, place it in the ~/Documents/AAIR/ dir and restart iChat.

All plugins have been updated to handle their own help request. Type ‘command /?’ to retrieve information on command.

The help plugin is now dynamic, to reflect the auto loading of the main AAIR script. Plugins added to the AAIR dir will auto show up in ‘help’.

v1.3 Beta

Adopted StefanK’s main AAIR script for stability

v1.2 Beta

Added theCommand list. All commands can be added to script from one central location.

v1.1 Beta

Added plugin functionality.

Todo
No issue present

Availible Commands:

Download:
v2.0 Beta
http://www.mediafire.com/?8z077qz8kbrdfzh

v1.3 Beta
http://www.mediafire.com/?2opkfa3lyii6eca --Uber thanks to StefanK’s fix & rewrite of the main AAIR Script!

v1.2 Beta
http://www.mediafire.com/?sfhtzlg20sl2ks0

v1.1.1 Beta
http://www.mediafire.com/?z323p5hhaa1qa1q

Any questions, please feel free post.

Plugin Template

property plugin : "missing" -- Replace 'missing' with exact name of plugin. No spaces. Example if I saved this plugin as time.scpt I would put the word time in place of "missing." 

on AAIR(theMessage, staticCommand, dynamicCommand, weatherLoc)
	
	try
		
		if dynamicCommand is "/?" then -- This is for returning extra information about plugin.
			set theResponse to plugin & "
	I am a command and I do stuff. But what Do I do? Edit theResponse to refelect my purpose."
			
		else
			
			(*your script starts here*)
			--Please note that you can add and call additional handlers. 
			
			
			
			
			
			
			(*your script ends here**)
			
		end if
		
	on error error_message
		set theResponse to (plugin & " Control. " & error_message)
	end try
	
	return theResponse
end AAIR

(*add additional handlers here if needed*)

Example Script Using Template - Simple

property plugin : "time" -- Replace 'missing' with exact name of plugin. No spaces. Example if I saved this plugin as time.scpt I would put the word time in place of "missing." 

on AAIR(theMessage, staticCommand, dynamicCommand, weatherLoc)
	
	try
		
		if dynamicCommand is "/?" then -- This is for returning extra information about plugin.
			set theResponse to plugin & "
	I am a command and I do stuff. But what Do I do? Edit theResponse to refelect my purpose."
			
		else
			
			(*your script starts here*)
			--Please note that you can add and call additional handlers. 
			set hour to hours of (current date)
			set Min to minutes of (current date)
			set theResponse to "Current Time: " & hour & ":" & Min
			
			
			(*your script ends here**)
			
		end if
		
	on error error_message
		set theResponse to (plugin & " Control. " & error_message)
	end try
	
	return theResponse
end AAIR

(*add additional handlers here if needed*)

Must be saved as ‘time.scpt’

Wow, this looks awesome, well done! I was trying to create something similar to this, but this just great - much better! I haven’t tried it yet, but I’ll try it when I get home.

If some of the commands weren’t so… Powerful, i think is the word. I would put up a live demo. I have it running on my Mac Mini Media Center. He has his own facebook page. XD Thanks!
Also feel free to develop plugins for AAIR. If you post them here I may include them in the next release. =)

:slight_smile: Cool!

However, I’ve had a bit of a problem with the installation. I get an error when launching the Installer - “error “File alias Macintosh HD:Users:Seb:Library:Scripts:iChat: of «script» wasn’t found.” number -43” or even running it in Script Editor :frowning:

It appears to have copied the folder but not the iChat script, so I copied it manually.

Also, instead of having a folder full of scripts, I’d be tempted to have say… 1 or 2 script libraries which can be read from which have a load of scripts or handlers inside them.

EDIT:

Furthermore, it would be useful to have a command like… “help” or “list commands” or something that could tell the person all of the available commands.

There is a ‘help’ command. And If you type help ‘command’ (e.g. help iTunes) you will get extra information on that command.

I will look into that error. I made some changes to the script before I bundled it and I am wondering if I didn’t update the installer. I think the issue with this might be the lack of a ~/Library/Scripts/iChat directory initially.

As for the script libraries, I am hesitant. It defiantly seems like a great idea, but I think it may be a little tricker for people later on to create their own ‘plugins’ if instead of just plugins they also have to edit a library. I will definitely give it some though though.

Help command: Oh right, guess I didn’t read the above properly! :expressionless:

Lack of iChat scripts directory: I don’t think so, I had an iChat scripts directory already with scripts in it.

EDIT:

I’m not sure if it’s supposed to be there or not but you left

display dialog "Command to test: " default answer ""
    set theMessage to the text returned of the result
    set theResponse to load(theMessage)
    display dialog theResponse

in the main iChat script, maybe it should be commented out, because it sometimes appears…

Oh no… I just tried out some commands after doing some coding myself and taking a look at your code and every time I type a command I get an error… “missing value doesn’t understand the AAIR message.”

Thanks for the heads up. I use that for debugging purposes. That will be commented out in future releases.

I did a fresh install of OS X 10.6.x and the installer was the first thing I tested. I do know that unless there was something there, the /scripts/iChat directory does not exist. Since yours did exists… According to a post here Error code -43 means something wasn’t found. I think it may be a typo in the installer.

No typo, the folder does not exist on a “normal” system. The installer should create the folder if there is none.

I’ve looked at the code and tweaked this and that, and put everything back to normal again but the commands still aren’t working… :frowning:

Also maybe you should wrap things in

try
            --Do something
            
        on error (err)
            send "An error was encountered:" & err to theChat
            
        end try

in case of an error

Did you edit the main script? You have to create a property for your command variable in the main script before the run handler.

property newCommand : missing value

In the run handler you need to set the plugin name with:

set newCommand to load script file (scriptLoc & "newCommand.scpt") -- newCommand.scpt is the name of the applescript plugin you made and placed in the plugin directory.

And lastly you need to add an else statement in the load handler

else if staticCommand is "New Command" then
set theResponse to newCommand's AAIR(dynamicCommand)

The else if part is a little tricky. The var theMessage, received from iChat, gets split into two other var’s “staticCommand” and “dynamicCommand”. It splits them base on the first " "(space) in theMessage. So if theMessage was “new command” staticCommand would be “new” and dynamicCommand would be “command”. If you want to pass either theMessage, staticCommand, or dynamicCommand through to your plugin you will need to add that var to the call e.g.

set theResponse to newCommand's AAIR(dynamicCommand)
--or
set theResponse to newCommand's AAIR(staticCommand)
--or
set theResponse to newCommand's AAIR(theMessage)
--or
set theResponse to newCommand's AAIR()

If you pass any var from the main script to the plugin, you will need to start your plugin to reflect that. So if you passed dynamicCommand you would have a plugin that looked similar to this:

on AAIR(dynamicCommand)
-- this is where your code goes
set theResponse to whatever
return theResponse
end AAIR

You need to make sure you return some sort of information from the plugin to the mainscript. For my plugins I would relay what my script jsut did for me.

theResponse is what get’s returned in chat.

Hope this helps. If you still need assistance post your plugin here and I can take a look at it.

Ah right! Thanks very much!! :slight_smile:

Any ideas on the “no commands working” situation?

None of the commands are working? If you haven’t edited the main script too much just pull the copy from the installer and overwrite it. Should clear things up. I only say that because trying to find one error in such a large script is quiet tricky. Do you receive any errors when you enter in a command that should work?

Yay! Thanks! Well done! It works great now, I’ve tried most of the commands.

Just as an FYI the kill commands does a kill -9 PID
Don’t know if that is relevant to anyone…

I’m currently at one of my college classes, but I will be working on the script. Hoping to get an update out before the end of the day. We’ll see though. Not making any promises. :rolleyes:

Also thanks magikseb for pointing out some of the bugs!

's ok! I tried making my own plugin to tell me my internal IP address…

on AAIR()
    try
        set internalIP to do shell script "ipconfig getifaddr en0"
    on error
        try
            set internalIP to do shell script "ipconfig getifaddr en1"
        on error
            set internalIP to "not found"
        end try
        
        set theResponse to "The internal IP of this computer is: " & internalIP
        return theResponse
    end try
end AAIR

…however, when I add the property at the top and missing value and then define it and hook it up to the script file and add in

else if theMessage is "internal IP" then
        set theResponse to internalIPCommand's AAIR()

all other commands stop working too… I then installed the original script under a different name and compared them. The only difference was the fact that I’d added in my own command the exact way you’d described in post 11.

Try placing

 return theResponse

outside of your try. Leaving it there will only send theResponse on an error.

on AAIR()
    try
        set internalIP to do shell script "ipconfig getifaddr en0"
    on error
        try
            set internalIP to do shell script "ipconfig getifaddr en1"
        on error
            set internalIP to "not found"
        end try
        
        set theResponse to "The internal IP of this computer is: " & internalIP
    end try
        return theResponse
end AAIR

Normally it is just something small that throw everything off. Give that a shot. If it doesn’t work let me know. Also (and a dumb question) is your else if inside the if statement in the main script?

Ok, I put

return theResponse

outside of the try, that made no difference. :frowning:

Yes, my else if is inside the if statement of the main script too…

if theMessage is "external IP" then
        set theResponse to externalIPCommand's AAIR()
        
    else if theMessage is "internal IP" then
        set theResponse to internalIPCommand's AAIR()

… there’s a little chunk.

:expressionless:

It’s really weird. I have put everything into my own version the exact way you have gave it to me and everything seems to work perfectly. I guess the only thing I can suggest is restarting your system. You internal IP plugin will be added to the next official release. I am also heavily considering a script library… The main issue I have with this (i’ve been thinking) is error handling. The more you add in one script the more tiny things can break odd parts of it.

Restarting hasn’t helped :frowning:

I’ve just gone back to the original script that works now.