Re: Ircle Script
Re: Ircle Script
- Subject: Re: Ircle Script
- From: JollyRoger <email@hidden>
- Date: Fri, 23 Feb 2001 22:35:20 -0600
on 2/23/2001 10:58 AM, Stephen Swift (aka Burnum) at email@hidden wrote:
>
At 2/23/01 1:03 AM, JollyRoger (email@hidden) Wrote:
>
>
>
>> #4 If connection fails switch server and repeat #3
>
>
>
> For this, you'll have to employ the connectionevent() handler:
>
>
>
> on connectionevent(con, e)
>
> tell application "ircle"
>
> if (e = namesearchfailed) or (e = ipsearchfailed) or (e =
>
> openfailed) then
>
> -- connection con failed
>
> end if
>
> end tell
>
> end connectionevent
>
>
This doesn't work out so great. Sure I've gotten Ircle to read it properly
>
and all, but I need some more help with some extra script lines.
>
>
What Ircle is doing is connecting and the script recognizes it connected so
>
it tells me the if statement is false. In the meantime, Ircle has
>
disconnected me because the servers were full. I can't use a delay because
>
I don't know how long it will take to either get connected or disconnected.
>
What about a repeat loop?
>
>
repeat until (status of connection 10 = connected)
>
get status of connection 10
>
if status of connection 10 is offline then
>
(*See Question*)
>
end if
>
end repeat
A repeat loop is not the best way to go here. What you need to do is watch
for the server error stating that the connection class is full. I just
tried a busy undernet server and got this message:
Closing Link: earthling by montreal.qu.ca.undernet.org (Sorry, your
connection class is full - try again later or try another server)
To trap this error message, you'll need to include the ircerror() handler in
your script. In this handler, you might want to test the contents of the
error string to see if it contains "connection class is full". If so,
you'll want to have the script try the next server.
on ircerror(con, source, sourcehost, str)
tell application "ircle"
echo "IRC Error: \"" & str & "\" on connection " & con & "."
end tell
if str contains "connection class is full" then
-- connection failed - try the next server
end if
return false
end ircerror
>
My question here is, is there away to stop a repeat loop? I'm not sure on
>
the syntax. Exit? Stop? Quit?
Yes, you can do:
exit repeat
>
>> #5 Join a channel
>
>
>
> This is as easy as:
>
>
>
> set chanName to "#testing123"
>
> tell application "ircle"
>
> type "/join " & chanName
>
> end tell
>
>
Yep...works fine.
>
>
>
> But, as I said in my first response, you'll have to be connected, and the
>
> server will have to be connected and ready for commands.
>
>
Again... I'm having problems with the timing. On running the script
>
AppleScript immediately tells me (command = 376) hasn't happened yet and
>
quits.
No, no, no. IRCLE calls that handler, not you! Did you read my reply to
your last message explaining how Ircle event handlers and loaded scripts
work??
You don't RUN the script, you LOAD the script into Ircle (either via the
/load command, or by setting the script as the Startup Script in Scripts
preferences).
on numeric(con, command, thestring)
if (command = 376) then -- end of MOTD (server should be ready now)
-- send server commands
end if
return false
end numeric
While the script is loaded into Ircle, IRCLE will call the numeric() handler
in your script whenever a numeric event happens, then your handler will have
to act appropriately.
>
One more question on the numeric handler:
>
>
> on numeric(con, command, thestring)
>
> if (command = 376) then -- end of MOTD (server should be ready now)
>
> -- send server commands
>
> end if
>
> return false
>
> end numeric
>
>
Ircle wouldn't run the script with thestring in the list, so I took it out
>
and it at least tried to run the script. Is thestring needed in this
>
example?
I'm not sure what you mean by "Ircle wouldn't run the script". Yes,
thestring is definitely needed in this Ircle handler. Ircle will definitely
expect thestring to be in the parameter list when Ircle calls the handler as
a result of a numeric event. I'm not sure what you are doing, but something
is wrong if you are having to remove a parameter...
>
After that Ircle gave me an error:
>
-10002 IRC got an error : Invalid Key form
Was that a result of you removing the thestring parameter?
>
I'm assuming it didn't like what I'm asking it to look for. I'm not sure
>
why.
Not sure either - I haven't seen any of your code. ;-)
>
> More questions? Ask away. :)
>
>
I know this is a lot of question, but this has got me baffled. Thanks.
>
BTW... Thanks for the events script. Mine wasn't complete for some reason.
Welcome.
JR
References: | |
| >Re: Ircle Script (From: "Stephen Swift (aka Burnum)" <email@hidden>) |