irc - Library irc.tcl
irc::listen on chan
irc::listen off chan
irc::listener add chan ?-thread? patlist script
irc::listener remove chan id
This is a to-spec IRCv3 client library. It is designed to be freely extracted.
"irc.tcl" provides 2 ways to connect to an IRC server.
Connects to hostname:port, and sets up all the necessary state. If usetls is set to true, the tls module will be used to connect, instead of the builtin socket command. If unset, socket will be used.
Channel metadata is initialized with proto, hostname, port, and uri set.
Sets up the internal state necessary for chan to be used as an IRC socket. It is called internally by irc::connect. This command is exposed for the use-case where an IRC channel might have a more bespoke acquisition process than a simple socket connection.
meta is the initial state of the channel metadata.
"irc.tcl" provides an event dispatch system, via a fileevent script registered on the IRC channel. Events are dispatched by matching their patterns against incoming messages.
Enable or disable the fileevent script for the dispatch system.
Apply the fileevent wrapper to chan. Returns the previous fileevent wrapper.
Remove the fileevent wrapper from chan. Errors if the channel does not currently have the irc handler set.
Configure listener-type event handlers.
listener-type handlers are scripts, executed in either a sub-interpreter or a seperate thread. Interpreter listeners should yield themselves with after during long operations, and never block for extended periods. If that is infeasible, threaded listeners are recommended.
listener-type scripts are spawned with the variable dispatch set to the channel they are to recieve dispatches over. Each line will be a dict with contents as described in Event Dispatch Contents. Interpreters are given access to the Dispatch-aliased IRC commands, while threads are given the variable parent, the ID of the main thread.
When a listener is removed, it will recieve a message of just end. It should perform necessary cleanup quickly, as the application is likely exiting. Threads may simply thread::release themselves, while interps may call the provided selfdestruct.
irc::listener add chan ?-thread? patlist script
Registers script as a listener-type handler on chan, using patlist as the Message Pattern List. Returns an id that can be passed to irc::listener remove or irc::patlist.
If -thread is passed, it will be created as a threaded listener, otherwise it will be created in a sub-interpreter.
Unregisters the listener identified by id from chan.
Ignores requests for nonexistent handlers or handlers of the wrong type.
Validation helper.