in Hacker School

Hacker School Day 3 – Zulip <-> IRC works!

Today is day 3 of Hacker School. I tried to get in earlier than 9:30 today, but got lost after Canal St. and spent my early time walking. I got in at 9:30.

I continued the trend of reading some blog posts when I got in to warm up and am still happy with that. I’ll stop talking about reading blog posts from now unless something awesome comes up. I did find lwan last night, which looks super cool. I also saw this new proof of concept on misconfigured SFTP servers — I want to prove the PoC and then examine what they’re doing to /proc/mem/maps.

Last night was fun. After I published Hacker School – Day 2, I got a message from someone that worked for Zulip before being acquired by Dropbox. They gave me some information about the undocumented APIs and were incredibly helpful! I also got some advice from Jessie Luehrs about actually making WebService::Zulip a real module. I didn’t work more on the module today, but will definitely be bugging him more in the future.

I started working on the transport code for the Zulip to IRC stuff. It’s working now, but needs some enhancements. Right now, it:

  1. Parses and verifies the options from the commandline
  2. Gets the Zulip credentials from the file specified by the user
  3. Instantiates a Zulip object from WebService::Zulip
  4. Daemonizes, then
  5. Creates two children: a reader and a writer

The reader is very simple and only a slightly modified version of the read-only client from the WebService::Zulip example I wrote yesterday. It gets a Zulip queue, opens the ‘in’ FIFO from the ii directory (with a hot handle), and reads new messages into the FIFO forever.

The writer opens the out file with File::Tail. It looks over the output and regexes out important information. If I want to talk to a stream in Zulip, I say something, and the log file gets updated. Here’s an example of me, sending myself a private message saying ‘testing2’:

2014-10-08 14:40 <stan_theman> [email protected]: testing2

The writer grabs “stan_theman” to make sure it’s me talking, ‘[email protected]’ to figure out who I was directing my conversation to, and ‘testing2’ to figure out what to say. Talking to a stream is similar:

2014-10-08 14:09 <stan_theman> Victory/IRC: if this shows up, I wrote this from irc!

The regex allows for the target (either a PM or stream) to have an optional slash in it, to allow for a stream name and subject. It does this for forever.

I had a bug earlier where I didn’t grab the ‘stan_theman’ part (the IRC name of the person talking). The bot would read itself, then send the command, then read itself again, and send that command, for forever. That bug was easy to see and easy to fix too.

I want to add some convenience features: it would be nice to automatically translate things like ‘<3’ into ‘:heart:’, and have the @mentions look up email address for easier PMing. I also need to expand the wrapper to include the information I got last night. I’m planning on presenting this tomorrow night at Hacker School, so it would be nice to have this ready by then!

Write a Comment

Comment