POE::Component::IRC::Plugin::BotAddressed - A POE::Component::IRC plugin that generates 'irc_bot_addressed' events whenever someone addresses your bot by name in a channel.
use POE::Component::IRC::Plugin::BotAddressed;
$irc->plugin_add( 'BotAddressed', POE::Component::IRC::Plugin::BotAddressed->new() );
sub irc_bot_addressed { my ($kernel,$heap) = @_[KERNEL,HEAP]; my ($nick) = ( split /!/, $_[ARG0] )[0]; my ($channel) = $_[ARG1]->[0]; my ($what) = $_[ARG2];
print "$nick addressed me in channel $channel with the message '$what'\n"; }
POE::Component::IRC::Plugin::BotAddressed is a POE::Component::IRC plugin. It watches for public channel traffic ( ie. 'irc_public' ) and will generate an 'irc_bot_addressed' event if someone on a channel issues a message which 'addresses' the bot.
It uses POE::Component::IRC's nick_name()
method to work out it's current nickname.
Two optional arguments:
'eat', set to true to make the plugin eat the 'irc_public' event and only generate the 'irc_bot_addressed' event, default is 0; 'event', change the default event name from 'irc_bot_addressed';
Returns a plugin object suitable for feeding to POE::Component::IRC's plugin_add()
method.
Has the same parameters passed as 'irc_public'. ARG2 contains the message with the addressed nickname removed, ie. Assuming that your bot is called LameBOT, and someone says 'LameBOT: dance for me', you will actually get 'dance for me'.
Chris 'BinGOs' Williams <chris@bingosnet.co.uk