-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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