~pkal/irc.awk

77efeae75cc17faa532f91196edf5dbafaf1342a — Philip Kaludercic 6 months ago d095400
Add auxiliary function irc_shell
2 files changed, 13 insertions(+), 0 deletions(-)

M DOCUMENTATION
M irc.awk
M DOCUMENTATION => DOCUMENTATION +5 -0
@@ 34,6 34,11 @@ Send a PRIVMSG to the actor/channel that triggered the current event.
Terminate the current connection with message "quitmsg". The variables
_msg and _len are local variables that shouldn't set.

*** irc_shell(cmd)
An auxiliary function that will execute "cmd" and send the output
using "irc_msg".  Please use this only if you are sure that the
command is sanitised.


*** READ(pat, to)
True when the message body of the current even matches

M irc.awk => irc.awk +8 -0
@@ 393,6 393,14 @@ function FROM(pat, to)   { return MSG && (WHO ~ pat) && (TO ~ to); }
function JOINED(pat, to) { return JOIN && (!pat || WHO ~ pat) && (!to || TO ~ to); }
function MENTIONED(to)   { return MSG && (MSG ~ ("^" __irc_nick ":")) && (TO ~ to); }

### Auxiliary functions

# Send the output of CMD using "irc_msg"
function irc_shell(cmd) {
    while ((cmd | getline line) > 0) irc_msg(line);
    close(cmd);
}

### Cleaning Up

END {