3 ms·
I wrote an IRC bot in it, one of those "paste a line of code and the bot will evaluate it and print the result" bots that you find in programming language chann
by Arnavion 4y ago
I wrote an IRC bot in it, one of those "paste a line of code and the bot will evaluate it and print the result" bots that you find in programming language channels. It's not a particularly big or "real" project, but it definitely fulfills the need of having a bot in that particular IRC channel.
awk is great for it because IRC (or at least the subset that the bot cares about) is relatively easy to parse, and shelling out the shell script that does the actual code evaluation and prints the result back is also fairly straightforward. Someone else used to have such a bot before but they had written it in Rust with a bajillion dependencies; if I had done that I would've had to update dependencies and redeploy it every other week. In contrast I deployed my awk version once and then basically haven't touched it in years.
- networked 4y agoThis sounded interesting enough that I went and found the source code on GitHub: https://github.com/Arnavion/evalr https://github.com/Arnavion/evalr. Starred. :-) The following caught my attention in the bash wrapper: coproc GAWK { gawk ... } <&"${GAWK[0]}" openssl s_client -connect "$IRC_SERVER" -quiet >&"${GAWK[1]}" This is a cool way to make awk talk over a socket that isn't specific to Gawk. For sockets without TLS you can replace openssl(1) with nc(1). I'll keep it in mind. Edit: You can also use http://www.dest-unreach.org/socat/ http://www.dest-unreach.org/socat/ and https://nmap.org/ncat/ https://nmap.org/ncat/ with awk: socat "OPENSSL:$host:$port" 'EXEC:awk ...' socat "TCP:$host:$port" 'EXEC:awk ...' ncat --exec '/usr/bin/awk ...' --ssl "$host:$port" ncat -e '/usr/bin/awk ...' "$host:$port"