views:

100

answers:

0

While writing an auto-relogin tool for iChat, I came across an interesting issue. Given the following script:

using terms from application "iChat"
    on logout finished for this_service
        delay 1
        display dialog (connection status of this_service as string) & ":" & name of this_service as string
        if status of this_service is offline then
            log in this_service
            delay 10
            if status of this_service is offline then
                log out this_service
            end if
        end if
    end logout finished
end using terms from

the dialog showing the connection status is shown twice, it would appear that it is shown once when logging out, and again after the account has logged in.

I am using 5.0.1 (743), and have only configured the script to run on the "When I log out" event, however it appears to be called twice. This would appear to be a bug in iChat to me, however I am new to Applescript, so maybe this is something that should be expected?

As an aside, the full script that I ended up with for auto-relogin is as follows:

using terms from application "iChat"
    on logout finished
        delay 30
        repeat with this_service in services
            if enabled of this_service is true then
                if status of this_service is offline then
                    log in this_service
                    repeat 10 times
                        delay 1
                        if status of this_service is not offline then
                            exit repeat
                        end if
                    end repeat
                    if status of this_service is offline then
                        log out this_service
                    end if
                end if
            end if
        end repeat
    end logout finished
end using terms from