POE::Component::IRC::Cookbook::Disconnecting - How to disconnect gracefully with PoCo-IRC
Shutting down an IRC bot can be quick and messy, or slow and graceful.
There are two ways you can shut down an IRC bot/client. The quick and dirty way is rather simple:
exit;
It exits the program, shutting down the socket, and everybody online sees yet another "Connection reset by peer" or "Remote end closed the socket" or something.
There's a little dance you can do to send a quit message and log out gracefully. It goes like this:
Send the QUIT command to the IRC server, with your quit message.
QUIT
Wait for irc_disconnected to come back.
irc_disconnected
Unregister all events. This is like the register => 'all' you probably posted near the connect command, but replace register with unregister. Once POE::Component::IRC knows your session isn't interested, it lets you go and things shut down.
register => 'all'
connect
register
unregister
Rocco Caputo (I think). PODified by Hinrik Örn Sigurðsson.
To install POE::Component::IRC, copy and paste the appropriate command in to your terminal.
cpanm
cpanm POE::Component::IRC
CPAN shell
perl -MCPAN -e shell install POE::Component::IRC
For more information on module installation, please visit the detailed CPAN module installation guide.