diff --git a/Changes b/Changes index e640a7d3..aec9b889 100755 --- a/Changes +++ b/Changes @@ -1,5 +1,9 @@ Revision history for Perl extension POE::Component::IRC. +4.64 Tue Jul 05 16:25:01 BST 2005 + - Fixed POD in Plugin::BotAddressed. + - Added BotTraffic.pm plugin. + 4.63 Thu Jun 16 21:55:49 BST 2005 - Fixed POD in BotAddressed and Connector plugins, thanks integral @ MagNET for spotting that one. diff --git a/MANIFEST b/MANIFEST index ac95f817..a4894668 100755 --- a/MANIFEST +++ b/MANIFEST @@ -2,6 +2,7 @@ Changes lib/POE/Component/IRC/Test/Harness.pm lib/POE/Component/IRC/Test/Plugin.pm lib/POE/Component/IRC/Plugin/BotAddressed.pm +lib/POE/Component/IRC/Plugin/BotTraffic.pm lib/POE/Component/IRC/Plugin/Connector.pm lib/POE/Component/IRC/Plugin/Whois.pm lib/POE/Component/IRC/Qnet/State.pm diff --git a/META.yml b/META.yml index f1e1ef90..11aab8cc 100644 --- a/META.yml +++ b/META.yml @@ -8,6 +8,8 @@ requires: Carp: 0 Date::Format: 0 POE: 0.0607 + POE::Component::Client::DNS: 0.98 + POE::Component::Client::Ident: 0.7 POE::Filter::IRCD: 0 Socket: 0 diff --git a/lib/POE/Component/IRC.pm b/lib/POE/Component/IRC.pm index 62414a5a..748f3c9a 100755 --- a/lib/POE/Component/IRC.pm +++ b/lib/POE/Component/IRC.pm @@ -26,7 +26,7 @@ use vars qw($VERSION $REVISION $GOT_SSL $GOT_CLIENT_DNS); # Load the plugin stuff use POE::Component::IRC::Plugin qw( :ALL ); -$VERSION = '4.63'; +$VERSION = '4.64'; $REVISION = do {my@r=(q$Revision: 1.4 $=~/\d+/g);sprintf"%d."."%04d"x$#r,@r}; # BINGOS: I have bundled up all the stuff that needs changing for inherited classes diff --git a/lib/POE/Component/IRC/Plugin/BotAddressed.pm b/lib/POE/Component/IRC/Plugin/BotAddressed.pm index b2b9c845..769bdcf6 100644 --- a/lib/POE/Component/IRC/Plugin/BotAddressed.pm +++ b/lib/POE/Component/IRC/Plugin/BotAddressed.pm @@ -80,8 +80,8 @@ No arguments required. Returns a plugin object suitable for feeding to Lchris@bingosnet.co.uk - - diff --git a/lib/POE/Component/IRC/Plugin/BotTraffic.pm b/lib/POE/Component/IRC/Plugin/BotTraffic.pm new file mode 100644 index 00000000..add9c10a --- /dev/null +++ b/lib/POE/Component/IRC/Plugin/BotTraffic.pm @@ -0,0 +1,96 @@ +package POE::Component::IRC::Plugin::BotTraffic; + +use POE::Component::IRC::Plugin qw( :ALL ); +use POE::Filter::IRCD; + +sub new { + return bless { @_[1..$#_] }, $_[0]; +} + +sub PCI_register { + my ($self,$irc) = splice @_, 0, 2; + + $self->{filter} = POE::Filter::IRCD->new(); + $irc->plugin_register( $self, 'USER', qw(privmsg) ); + return 1; +} + +sub PCI_unregister { + return 1; +} + +sub U_privmsg { + my ($self,$irc) = splice @_, 0, 2; + my ($output) = ${ $_[0] }; + + my ($lines) = $self->{filter}->get([ $output ]); + + foreach my $line ( @{ $lines } ) { + my ($text) = $line->{params}->[1]; + next if ( $text =~ /^\001/ ); # Skip over CTCPs + foreach my $recipient ( split(/,/,$line->{params}->[0]) ) { + my $event = 'irc_msg'; + $event = 'irc_bot_public' if ( $recipient =~ /^(\x23|\x26|\x2B)/ ); + $irc->_send_event( $event => [ $recipient ] => $text ); + } + } + return PCI_EAT_NONE; +} + +1; + +__END__ + +=head1 NAME + +POE::Component::IRC::Plugin::BotTraffic - A POE::Component::IRC plugin that generates 'irc_bot_public' and 'irc_bot_msg' events whenever your bot sends privmsgs. + +=head1 SYNOPSIS + + use POE::Component::IRC::Plugin::BotTraffic; + + $irc->plugin_add( 'BotTraffic', POE::Component::IRC::Plugin::BotTraffic->new() ); + + sub irc_bot_public { + my ($kernel,$heap) = @_[KERNEL,HEAP]; + my ($channel) = $_[ARG0]->[0]; + my ($what) = $_[ARG1]; + + print "I said '$what' on channel $channel\n"; + } + +=head1 DESCRIPTION + +POE::Component::IRC::Plugin::BotTraffic is a L plugin. It watches for when your bot sends privmsgs to the server. If your bot sends a privmsg to a channel ( ie. the recipient is prefixed with '#', '&' or '+' ) it generates an 'irc_bot_public' event, otherwise it will generate an 'irc_bot_msg' event. + +These events are useful for logging what your bot says. + +=head1 METHODS + +=over + +=item new + +No arguments required. Returns a plugin object suitable for feeding to L's plugin_add() method. + +=back + +=head1 OUTPUT + +These are the events generated by the plugin. Both events have ARG0 set to an arrayref of recipients and ARG1 the text that was sent. + +=over + +=item irc_bot_public + +ARG0 will be an arrayref of recipients. ARG1 will be the text sent. + +=item irc_bot_msg + +ARG0 will be an arrayref of recipients. ARG1 will be the text sent. + +=back + +=head1 AUTHOR + +Chris 'BinGOs' Williams [chris@bingosnet.co.uk]