Okey so I tried out the code in my previous reply.
Firstly the console didn’t print properly and was basically delayed by about 5-6 messages. So when I typed something in the IRC chat, another old line would be printed in the console (although delayed of course).
Also the bot disconnected once again, sadly.