Sonofawitch, the GAWK Logbot

October 15th, 2020 by Diana Coman

Since active people nicely asked me for the code of my GAWK logbot, I took the time to genesis it, for whatever use they may have for it. As always, the only possible author of some code is its reader, not its writer, so don't run "my" code, but read it and make it yours in whatever way suits your need and your environment (don't expect it to just suit blindly anything and everything either because it most certainly won't). The bot's code is commented in enough detail to make its purpose quite clear so I won't repeat any of it in this article but I'll give instead some background on it, since this goes way beyond what fits or indeed belongs at all times in the code comments.

My prototype GAWK logbot code ran in my irc chan, #ossasepia, under the name of Sonofawitch, between April 2020 and the closing of the chan in September 2020. The more recent articles in the logs category are the fully automated output of this log code. The raw logs for #ossasepia and #eulora are dumps of the bot's raw loglines database.

The code itself grew from the original 140 lines of code to 413 lines currently (including rather detailed comments), mainly because the bot's use got cut short when I closed my chan, so that the bot basically ran out of time before it got to move out of the prototype stage. As a result, the current logbot code includes not only the logging of irc lines but also the trial (that turned out to work perfectly well) formatting and create/update of log-articles for real-time publication on a mp-wp powered blog. This piling of both functions in the logbot code was meant only as an initial easy way to test what I had never attempted before, namely to just create and update automatically and on the fly articles in a mp-wp database. There were for that matter some initial unexpected findings (iirc there was some flag that needed set for the publishing of a new article to happen) and some tweaks to make such as adding the change of day, so the testing itself was valuable as far as I'm concerned but it's true that over its last couple of months the bot simply ran perfectly smoothly and without any trouble.

The next step was meant to be a full decoupling of logging from publishing: the latter is best handled perhaps directly through a MySQL trigger function so that the bot itself does not need to be concerned with that and can return both to its nearly-microscopic original size and its simpler focus on writing the raw lines as they come and citing lines from known URLs. Nevertheless, since my need for irc-logging turned out to be non-existent at this time after all, there was no reason to spend any further time on this and so the poor bot remained as it currently is, despite its perfect and long-enough functioning in the field otherwise.

The genesis .vpatch for the bot code and my sig for it are as usual on my Reference Code Shelf and linked here as well, for your convenience:

Comments feed: RSS 2.0

2 Responses to “Sonofawitch, the GAWK Logbot”

  1. Jacob Welsh says:

    Thanks Diana! Looking forward to studying this code.

Leave a Reply