Skip to content

Instantly share code, notes, and snippets.

@jkbbwr
Forked from ilmoeuro/ircbot.awk
Created August 8, 2016 11:52
Show Gist options
  • Save jkbbwr/af2858744593c2ce30f631d219b81570 to your computer and use it in GitHub Desktop.
Save jkbbwr/af2858744593c2ce30f631d219b81570 to your computer and use it in GitHub Desktop.
AWK ircbot, usage with ncat is left as an exercise for the reader
function message(str) {
system("sleep 0.1");
printf("%s\r\n", str);
printf(">>> %s\n", str) > "/dev/stderr";
system("sleep 0.1");
}
{
printf("<<< %s", $0) > "/dev/stderr";
if (! initialized) {
message(sprintf("USER %s %s %s :%s", nick, nick, serv, nick));
message(sprintf("NICK %s", nick));
message(sprintf("JOIN #%s", chan));
initialized = 1;
}
}
$2 == "PRIVMSG" && $4 ~ /^:!uptime.*/ {
"uptime" | getline uptime;
message(sprintf("PRIVMSG %s :%s", $3, uptime));
message("");
close("uptime");
}
$2 == "PING" {
message("PONG");
message("");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment