Re: Ircle Script
Re: Ircle Script
- Subject: Re: Ircle Script
- From: JollyRoger <email@hidden>
- Date: Sun, 25 Feb 2001 02:18:46 -0600
on 2/24/2001 10:41 PM, Stephen Swift (aka Burnum) at email@hidden wrote:
>
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.
Welcome. Don't mention it - I'm glad to help.
>
> 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:
(snip)
>
However, Ircle just uses the first handler (on ircerror) - I suspected it
>
would. So the two handler idea doesn't work. Any ideas?
Nah, you Ircle is only looking for one handler for each event.
If each of your 10 connections is set up already, then why not just try the
next connection each time:
on ircerror(con, source, sourcehost, str)
if str contains "No more connection" then
tell application "ircle"
disconnect connection con -- disconnect from the connection with
the full server
connect connection (con + 1) -- try the next connection
end tell
end if
return false
end ircerror
If instead, you have a list of servers that you want to connect to, then you
could just use one connection and change the server name each time you want
to try a new server - something like this:
property serverNames : {"devlin.openprojects.net",
"norton.openprojects.net", "adams.openprojects.net",
"rice.openprojects.net", "etc..."}
on ircerror(con, source, sourcehost, str)
if str contains "No more connection" then
tell application "ircle"
-- disconnect from the connection with the full server
disconnect connection con
-- advance to the next server in the list
set x to my ServerNameOffset(servername of connection con)
if x > the (count of serverNames) then -- smaller than or equal
to
set servername of connection con to (item (x + 1) of
serverNames)
else
set servername of connection con to (item 1 of serverNames)
end if
-- connect to the next server now
connect connection (con + 1)
end tell
end if
return false
end ircerror
on ServerNameOffset(sName)
set match to 0
repeat with sn from 1 to the count of serverNames
if (item sn of serverNames) = sName then
set match to sn
exit repeat
end if
end repeat
return match
end ServerNameOffset
(I haven't actually tested this code... But eve if it doesn't work correctly
the first time, you should get the idea...)
JR
References: | |
| >Re: Ircle Script (From: "Stephen Swift (aka Burnum)" <email@hidden>) |