AWK Paste

It's been a long time coming...I figured out how to make it work about a year ago, and never did it.

The time has finally been taken to add an paste bin extension to awkbot. The connectivity was abstracted from gawk by using netcat, which enabled using temporary files for IPC in awk. The necessary tempfile markers were put in a table in a mysql database, using the mysql.awk extension, and a CGI library was drafted for awk. A CGI application was written in awk which pulls the tempfile information from the mysql database, and injects notifications into awkbot's incoming stream. Awkbot was extended to identify these non-IRC notifications and take action on them, notifying the channel of the new paste.

Syntax hilighting was added by making use of vim's 2html.vim script, packaged in the VIM distribution since version 6 atleast. The file being rendered is stored into a temprorary file in the system's tempfs, then opened in vim and run through 2html. The 2html buffer is then stored as a second temporary file, which is relayed to the client. The output is filtered as to inject a heading into the file output to note the author of the paste, the paste link, and the subject supplied at paste time.

The exercise was to use nothing more than awk and general system tools to build a full function paste bin for use in freenode's #awk IRC channel. It works! And it's rather pure at that.

This version of awkbot also removes yet a few more gawk dependencies. Some time or other, portability testing will begin to ensure that awkbot is capable of running on other awks. Other external dependencies were added however. Most notably, vim.

Comment by scott on Sun Mar 2 19:50:25 2008

For performance reasons and due to the default vim theme set all including yellow in their colour schemes, vim was replaced with Andre Simon's highlight(1). This resulted in a significant performance increase and a bit less thrashing. Also, since CPP is a part of the startup process macros were added to allow switching between opening up highlight as a co-process (gvim specific) or still using the tempfiles.

Add comment