Implements principal protocol

Passes test: it properly interprets all data given by weechat's
test command.