Py Protobowl Bowl Py

Dec 27, 2017

Winter break’s here, so I decided to spend some time off making a way to programmatically interface with Protobowl

The main goal of this was to prototype and then port code to Swift as iOS 10 has broken mobile Protobowl. Also out of some morbid desire to beat my quizbowl teammates at their game, an auto-answer bot was developed alongside API code.

Of course, I’ve already tried this multiple times in the past with varying levels of success:

  • The first one: found PB source then gave up
  • Do it through HTTP: yeaaahhh…
  • Found ProtoBot in Java: promptly gave up afterwards

I’m a bit pragmatic as you can see, mostly since I wasn’t going to burn a week on this kind of thing-whoops.

From what I understand, PB upgrades HTTP requests to the websocket protocol and then sends JSON files between client and server. I was able to see this using Chrome’s Network tab, but the problem remained: How to upgrade HTTP to websocket?

On a whim, I requested a socket from PB using HTTP and tried plugging the websocket address into a websocket client which…worked. Huh. Cool.

Over the next few days, it was a matter of implementing many PB commands to be sent as JSON. Thankfully, Python’s json library dumps JSON nicely and PB’s not that strict with parsing, so I can just ignore the command headers for the most part.

Sample run of the bot:

Sample run of bot

Among various minor annoyances and roadblocks include:

  • PB disconnects idle users, so I need to constantly ping the site
  • PB sends packets as general “sync” packets which just contain a bunch of info. Of course, these things are a a mess to identify and dig through.
  • Parsing data received is still incomplete. While unnecessary for an auto-answer bot, I want it for a future client.

The plan as of now is to focus on porting to Swift and then figure out how to best parse incoming websocket data. Xcode grievances are worth another day though.


Much of this project owes itself to ProtoBot which was a huge help in reference.