EXTERMINIATE

A long time ago, in a classroom far, far away, I spent class time that would had otherwise be used for listening to teachers drone on about things of little importance, writing a bot for IRC in mIRC. It didn’t do much, but it responded to some words, executed some commands, and pestered some people who didn’t like automation in their lives. Although those days are long past, thanks to the adoption of HipChat at work, and an internal IRC testing environment successfully built, I am revisiting the idea of a chat bot once more. This time, it’s super serial.

I often have to remind my co-workers that I have zero real-world programming experience, and little-to-no knowledge of programming languages. Often I can stare at some code and possibly figure out what it was intended to do, but the act of writing it has eluded me. Most of that has myself to blame, I’ve been exposed to it all of my life in many ways, but I never latched onto it very well. I favored tinkering with hardware and manipulating operating systems and existing software packages. Hell, I’ve probably learned more about programming and source-control over the past month than I have in twenty-eight years, and I still don’t really know what is what still. There seems to be a lot of ways to do shit, between GitHub, Bitbucket, and all the such. I would like to sit down and learn something, but I have to be doing something or making something along the way to really pull anything out of it, much like how I taught myself HTML when I was a teen to design websites. Simply learning a language or anything doesn’t do anything for me unless I have something interesting to apply it to, because I am horrible and have no attention span.

So when we started using HipChat at work, a co-worker found a bot written in Coffeescript on Node that functioned as a chat bot that could do a variety of things. Ours can connect to our JIRA, Salesforce, and a number of other tools we use and provide useful information, as well as fun stuff like generate image memes from Memegenerator. As I looked into the page on it and associated info, I found that it could be run on other platforms, including IRC. Having cobbled together an IRC server for some various projects on my webserver, I thought it’d be cool to poke at making a real bot with more flexibility than a simple bot written in mIRC or KvIRC. So I set up on GitHub and forked a repo of the hubot-scripts to take a stab at learning something semi-useful. The name “Thursday” came from Disgaea: Hour of Darkness being the robot companion of Gordon and Jennifer.

Getting Hubot running in IRC was… er.. a challenge. There isn’t much in the way of documentation on the site or by anyone involved in the project, so I had to rely on my own and a few notes from our setup at work to get my own going. I realize the true test of a nerd is that you have to do your own work, break and fix, and all that, but it probably couldn’t kill someone to come up with some tad better documentation to avoid some of the stupid pitfalls. That said, I mixed downloading the current version tar with using NPM to fine-tune the install after unpacking the tar into a directory. At first I went with /opt/hubot but then ended up making another user account and setting up in the home directory. This was after trying, and not exactly understanding how to set it up as a daemon. More on that in a minute. The instructions were simply to unpack, add hubot-irc to the package file, and running npm install after.

While this gets you up and running fairly quickly, you have to make sure, at minimum, the shit for coffeescript is in there as well as a number of other dependencies if you want to run most of the scripts found in the hubot-scripts repo. What confused me early on when I was looking into our Hipchat repo I cloned from Bitbucket was that it mentioned scripts being located in the scripts folder, and then a file to define which scripts you wanted active. That seemed simple enough to me, but then in talking to the dude to set it up, he confused me with some other process it was using to fetch and load scripts. As it turns out, you can do some bullshit magic to pull scripts from the hubot-scripts repo and just define which ones you want active from the file, without needing to grab the script yourself and add it. I found out how much of a pain this ends up being when my npm install did fetch the directories and add the scripts, but then it had its own local script folder from the base install that was causing outputs to show up twice. Deleted that, fixed. Then later on, when adding a script I was testing of my own, it wouldn’t pick it up until I made a scripts folder again and added it to it. But then I had to copy it back. Are you confused yet? Because I am, fuck! TL;DR is I got mine working, but fuck if I know how sometimes. I have a tree of something like 2,000 files and they all seem to be copies of itself nested into each other, like fifty mini-hubots all working in some kinda tandem. I don’t know if that’s the things true purpose, but it seems to discombobulated and pointless, like someone could’ve designed something that works on less files, but deliberately made it this way to achieve some kinda higher purpose. I dunno.

After I got it working and swore not to fuck it up any worse, I started fiddling with the Memegenerator script. My goal was to add some additional generators. This required me to first figure out how Coffeescript works, or at least how Javascript works, and how to word the text. Most of the memes they had in there were pretty simple, and I was able to craft a new entry for WillyWonka pretty easily after understanding how Memegenerator’s API worked into the script. But with WillyWonka, folks use several different top and bottom statements. The standard phrase goes something like this where it begins with “Oh” and finishes with “Please”. But variations have cropped up where it might begin with “You” and end with “Tell” such as this. So I tried to see if I could make it so that it would go with either variation. That’s when I realized I didn’t know much about the language, but the guy showed me how that shit works and a site to validate the expressions before putting it into the script that would also help. So I call that a good step forward. I was able to complete that and “Bad Time Ski Instructor” and test those in IRC, which work.

The conclusion is, while this program is a goddamn rubix cube of terrible, the output is pretty fun, and if I can get a grasp on the language used, I’d like to develop some scripts for IRC similar to what I did for Misakichi back in 02, but also to make some scripts to “humanize” the bot by allowing it to respond to conversation like a person would in real-time. Then I’ll slip it into HipChat and prove just how predictable everyone’s speech pattern are. >=D

This entry was posted in Blog Dot and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *