~ecs/i

Simple IRC client
Add support for implied-channel /part

refs

master
browse  log 

clone

read-only
https://git.sr.ht/~ecs/i
read/write
git@git.sr.ht:~ecs/i

You can also use your local clone with git send-email.

#i

Simple IRC client written in POSIX shell

#Usage

./i

#Notes

i maintains two FIFOs: an input FIFO and an output FIFO. The input FIFO is piped into the server, and the output FIFO is piped out of the server.

Unless noted otherwise, $1 is the path of the input FIFO, $2 is the path of the output FIFO, and $@ refers to $3 and onward.

#Configuration

$XDG_CONFIG_HOME/i.conf will be sourced on startup. (If $XDG_CONFIG_HOME is unset, ~/.config/i.conf will be sourced.)

The function on_start will be run on startup. $@ is i's $@ The default on_start identifies the user as $USER.

The function handle_input will be called on input from the server. It should return 0 when it doesn't handle the input and 1 when it does. $3 is the prefix (usually the channel name), $4 is the command, and the remaining arguments are the rest of the input line. The default handle_input always returns 0.

The function server will be called in order to set up the input and output FIFOs. The default server ignores SIGEXIT and runs ncat --ssl to irc.freenode.net:6697.

The function handle_command handles commands (anything input that matches ^/[^/]). $@ are the space-separated words in the command. handle_command should return 0 when it doesn't handle the command, and nonzero when it does. The default handle_command calls default_handle_command, which is separated from handle_command in order to allow your handle_command to handle default commands.

#Useful functions

getchar prints the $2nd character from $1

next prints the first space-separated field of $1, stripping control characters.

rest prints everything but the first space-separated field of $1.

ident identifies you as $3.

cleanup shuts down i.

default_handle_command handles some non-IRC commands which are expected to exist. Run /help to see them. default_handle_command returns 0 if it doesn't handle the input and 1 if it does.