Last active
May 13, 2022 23:43
-
-
Save ilmoeuro/78933ad47c947fde83c6f78a2e24dbc3 to your computer and use it in GitHub Desktop.
AWK ircbot, usage: `ncat -c 'awk -v nick=nick -v serv=serv -v chan=chan -f ircbot.awk' <host> <port>`
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