It’s the second day of Hacker School. I got here around 9:30am. I started this morning by reading a couple of articles. Normally I’d feel a little guilty about this, but it was good to have some coffee and warm up. I kicked today off by working more on converting my throwaway perl script into WebService::Zulip. For some reason I never get excited about doing this. Today was not very different.
- Converted all the calls in the /examples directory to pull my credentials from a file, so I could actually commit code.
- Tried to use a private API. If you investigate the network requests being made while Zulip is open in the browser, you’ll see plenty of private API calls. These calls give you previous messages, and plenty of other awesome features. I spent time trying to see if there was a public equivalent. I started working on integrating the private methods into the API wrapper, and then felt bad and stopped.
- Ignored errors. I need to handle errors better in the wrapper. I’m not checking for failures in JSON decoding, and I’d like multiple error levels for the user (die on error vs warn).
- Ignored CPAN. I need to actually set up all the crud that is needed to make it a module-proper. This is usually the part where I fall asleep.
- Got upset with lies. The Zulip docs claim that they have a well-documented API, and go on to describe 3 methods. The python module has 8 functions. I need to add these options.
Today I pushed WebService::Zulip to GitHub. I threw some examples inside the /examples directory, including a read-only client. On my Linode, I installed ii, an IRC client that uses FIFOs to communicate. I’ve been really excited about ii for a while, and this was the perfect use case. I joined it to IRC by echoing into a FIFO. I have a channel with the ii bot and myself, and ran my read-only zulip example code, redirected to the FIFO.
I hit a snag for a few minutes when I wasn’t seeing any output in IRC before I remembered buffering. Mark Jason Dominus has a wonderful article on buffering, lovingly titled “Suffering from Buffering“. He’s a prolific writer. I just ordered a used copy of his “Higher Order Perl” book on Amazon. It’s free online but is too fantastic not to own.
At 4:00pm I went to a discussion by Crista Lopes on monads. It was good to get some more understanding of that under my belt. I’m hoping that by hearing this stuff enough, I might become interested enough to try it. Who knows!
The next step is to actually break out the bot part. I need a wrapper script to daemonize the ii bot, then write a perl script that forks off two children:
- One to pump data into the in fifo. This will probably be a massaged version of the read-only example.
- The second to tail the out file. Both children will use WebService::Zulip, and the out monitor can look for responses from me to forward to Zulip. If it sees responses in the form of “^(Channel|name): .*$”, send to Zulip. This should be straightforward, and is a good stopping point if integrating with bitlbee is a pain.
Bitlbee would be nice though, because then I could tab-complete other people’s names.
I also spent about an hour with Sumana Harihareswara to help her understand aspects of hosting. She wrote a wonderful blog post called “Some Tips on Domain Names and Hosting” summarizing her research and some of my yapping, too. It was a great time.