A little while ago, I related how I'd been playing with Irssi and POE, well today I've been playing some more >:o)
Since my first journal entry on this subject, Martijn van Beers has released POE::Session::Irssi which makes the whole business of integrating Irssi and POE that little bit easier.
I wanted to see if I could run a POE::Component::IRC bot inside Irssi.
I had a bot called flibblebot that I have been playing with on Freenode for a while. So I took the source to that and started fiddling.
First I switched the POE::Session to use POE::Session::Irssi. Then had to change all my handlers to inline_state from package, as POE::Session::Irssi currently doesn't support object or package state handlers. Suck.
Then I started the script up in Irssi and it worked! Hurrah!
Except that I had left in print statements that spat debug info into my active Irssi window ... everytime someone said anything in one of the channels the bot was on. Doh.
Try to unload the script to find, that bot won't die. Damn it, POE::Component::IRC is not Irssi aware and is holding the POE::Session::Irssi open. Then I remembered that one can send PoCo-IRC a 'POCOIRC_SHUTDOWN' signal to tell it to .. erm .. shutdown. I wrote another small script to do that. Yay! The bot dies and I can unload the script now.
Right, I need to bind an Irssi command to terminate the bot
The final bot code is here
Postscript:
I have since been corrected about package_states. Irssi wraps scripts as Irssi::Script::scriptname-minus-pl I have adjusted the bot code accordingly