Re: Ircle Script
Re: Ircle Script
- Subject: Re: Ircle Script
- From: JollyRoger <email@hidden>
- Date: Fri, 23 Feb 2001 00:03:05 -0600
Whoa there, Stephen...
It sounds like there is something very fundamental about Ircle scripting
that you are miscomprehending. I'll try to set you straight.
Be prepared...you are about to discover what I consider to be one of the
most functional and powerful AppleScript implementations in a Macintosh
application! Ircle just plain rocks! :)
There are two types of Ircle scripts: loadable scripts, and run-once
scripts. In order to process the type of information you want to process in
your script, you'll need to make a loadable script.
Runnable scripts run once, end, and that's it. There are lots of things you
can do with runnable scripts; but more powerful things can be accomplished
with loadable scripts.
Loadable scripts are loaded either by typing "/load scriptfilename" into an
Ircle window, or by Ircle at startup when the Startup Script setting (In
Scripts preferences) points to the script file.
While a script is loaded in Ircle, Ircle sends certain events to the script.
if the script wishes to "intercept" (read "handle") one of these events, the
script must have a handler for that event. The event handlers I gave to you
are Ircle event handlers. Ircle calls them, not you. Ircle calls them when
the corresponding event occurs. In other words, when your script is loaded
and a connection event occurs, Ircle calls the connectionevent() handler in
your script.
Questions?
I'll respond to the rest of your post below...
on 2/22/2001 9:17 PM, Stephen Swift (aka Burnum) at email@hidden wrote:
>
My Script Goals:
>
#1 Specify a nick to use
Do you want the user to specify the nick, or do you just want the script to
have a variable/property to hold a static nick?
>
#2 Specify A Server to connect to
Same question: Do you want the user to specify the server, or do you just
want the script to have a variable/property to hold a static server?
Both #1 and #2 can be done fairly easily. Try this for a start:
tell application "ircle"
set myConnection to connection 10
set myConnection's servername to "some.server.com"
set myConnection's nickname to "Nickname"
end tell
>
#3 Connect
tell application "ircle" to connect connection 10
>
#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
>
#5 Join a channel
This is as easy as:
set chanName to "#testing123"
tell application "ircle"
type "/join " & chanName
end tell
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.
>
> Did you know there is a list dedicated to ircle scripting? The ircle web
>
> site (http://ircle.com/related.shtml) has instructions on how to subscribe.
>
>
CCing this reply to them as well
Cool. I haven't seen it posted yet over there.
>
> I'm sure I can help. What have you tried so far? What isn't working? Give
>
> specifics.
>
>
Lots. Read on for the specifics.
Okie dokie. :)
>
> You should have received a script called "events" with your ircle package.
>
> To start, take a look at connectionevent().
>
>
I found the events script but couldn't find the connectionevent() handler
>
but took a look at the one in your e-mail.
Ok, well I've sent mine to you. It's got all of the event handlers defined.
>
> on connectionevent(con, conevent)
>
> -- con : connection number (1..10) NUMBER
>
> -- con: 11 and up for dcc connections (NEW)
>
> -- coneevent: one of namesearchfailed,
>
> ipsearchfailed,namefound,ipfound,openfailed,established,closing,pleaseclose,
>
> closed
>
> tell application "ircle"
>
> display ("connection " & (con as string) & " event")
>
> end tell
>
> end connectionevent
>
>
*NOVICE APPLESCRIPT ALERT* Handlers and I don't work together. I could
>
never figure them out. How do I get this handler in action?
You load the script into Ircle, and Ircle calls the handler when connection
events occur.
>
connectionevent(5,established) ?? --> IRC doesn't do anything.
You aren't supposed to call the Ircle event handler - Ircle is.
>
> 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
>
>
Again I'm trying to figure out how to work it.
>
>
numeric(5,type,"server should be ready now") ??
>
-- send server commands - this is where I tell IRC to do stuff right?
No, ***Ircle*** calls this handler, not you. The handler is expected to
examine the con, command, and thestring parameters to see what the numeric
command is, what connection the numeric event applies to, and what message
(if any) was associated with the numeric command.
>
What does return false do?
For ALL Ircle event handlers, you should return a true or false value. True
indicates that you handled the event yourself, and Ircle should ignore it.
False indicates that you did not handle the event, and Ircle should process
it.
>
What about something like this:
>
>
Connect connection 5 -- seems to work if the server I want to use is setup
>
for connection 5
Yep.
>
But if I want to specify servers it looks like I have to use:
>
Type "/server irc.theserver.com"
Nope. There's a better way. (See above.)
>
I'm trying to create a script for Ircle to do the following:
>
Connect to a server
>
>
And to check if the server connected could I use:
>
>
Repeat until status of connection 5 = connected
>
Connect connection 5
>
End repeat
Use the conectionevent() handler for this job.
>
> If server is full connect to another server
>
>
I think I found the right component with the status
>
offline/namelookup/opening/connected/userclose/serverclose command but I'm
>
not sure how I would make AS to keep checking. A repeat loop perhaps?
>
>
Repeat until status of connection 5 = connected
>
Connect connection 5
>
End repeat
No. Use the connectionevent() handler.
>
But how would I change servers if status = offline or serverclose?
>
Something like this perhaps?
>
>
Repeat until status of connection 5 = connected
>
If status of connection 5 = offline then
>
Type "/server dal.net"
>
Else
>
If status of connection 5 = serverclose then
>
Type "/server dal.net"
>
Else
>
If status of connect 5 = connected then
>
Type "/join #channel"
>
End repeat
No, just write your connectionevent() handler to detect the "established"
event.
More questions? Ask away. :)
JR
References: | |
| >Re: Ircle Script (From: "Stephen Swift (aka Burnum)" <email@hidden>) |