Re: Ircle Script
Re: Ircle Script
- Subject: Re: Ircle Script
- From: "Stephen Swift (aka Burnum)" <email@hidden>
- Date: Sat, 24 Feb 2001 23:41:48 -0500
At 2/24/01 6:05 PM, JollyRoger (email@hidden) Wrote:
Ahh... Am I ever going to stop questioning you about this script? I'm very
thankful your being so helpful. I'm almost done. I have a question about
one of your suggestions.
>
>
>
> Okay this script works great. Except, (Don't you just love all my question?
>
> =) ). What if I wanted to do something if I got an error from the second
>
> server? Too bad you can't put a handler in a handler.
>
>
Hi Stephen,
>
>
No need to do a handler in a handler. This handler will work for any
>
connection. Just examine the "con" parameter to see which connection(and
>
hence, which server) caused the error:
>
>
tell application "ircle"
>
echo "IRC Error: \"" & str & "\" on connection " & con & " (" &
>
servername of connection con & ")."
>
end tell
>
-- watch for line wraps (above) caused by the list server
But how would that work? Here is an example script:
on ircerror(con, source, sourcehost, str)
tell application "IRCle"
echo "IRC Error: \"" & str & "\" on connection " & con & " (" &
servername of connection con & ")."
if str contains "No more connection" then
disconnect connection con
set con to connection 5
set con's servername to "tsunami.ma.us.dal.net"
connect connection con
end if
end tell
return false
end ircerror
Now when the second server fails, the handler is run. It goes through and
sees my first if statement, and follows the instructions which tell it to
connect to the server that just failed. See what I'm saying? So the
solution I'm thinking of is using a different variable for my second
connection. Then I would have to add another handler to the script like
this:
on ircerror(con, source, sourcehost, str)
tell application "IRCle"
echo "IRC Error: \"" & str & "\" on connection " & con & " (" &
servername of connection con & ")."
if str contains "No more connection" then
disconnect connection con
set con2 to connection 6
set con2's servername to "tsunami.ma.us.dal.net"
connect connection con2
end if
end tell
return false
end ircerror
on ircerror2(con2, source, sourcehost, str)
tell application "IRCle"
echo "IRC Error: \"" & str & "\" on connection " & con2 & " (" &
servername of connection con2 & ")."
if str contains "No more connection" then
disconnect connection con2
end if
end tell
return false
end ircerror2
However, Ircle just uses the first handler (on ircerror) - I suspected it
would. So the two handler idea doesn't work. Any ideas?
>
>
>
Careful below..."disconnect connection" doesn't specify WHICH connection -
>
if I were you, i would use "disconnect connection con".
Good idea.
>
>
> disconnect connection
>
>
> on numeric(con, command, thestring)
>
> tell application "IRCle"
>
> if (command = 376) then -- end of MOTD (server should be ready now)
>
> beep
>
> else
>
> beep
>
> end if
>
> return false
>
> end tell
>
> end numeric
>
>
Ahhh, after looking closer, I see the problem. Did you notice that I
>
changed the word "command" to "cmd" in the numeric handler above?
Ahh Ha! I thought it was trying to do something with the keyword 'command'.
I look back onto the events script and see command is in | | which makes
sense. This makes all the difference. Thanks. =)
Stephen Swift ?' The Burnum Man
email@hidden
It9s Coming Back! AppleInfo.net - Check Back Soon
-----------------------------------------------
"If I were running Apple, I would milk the Macintosh for all it9s worth and
get busy on the next great thing." -Steve Jobs, Fortune Interview in Feb.
96