Kwiki-Notify-IRC
view release on metacpan or search on metacpan
lib/Kwiki/Notify/IRC.pm view on Meta::CPAN
const class_id => 'notify_irc';
const class_title => 'Kwiki page edit notification via IRC';
const config_file => 'notify_irc.yaml';
sub register {
my $registry = shift;
$registry->add( hook => 'page:store', post => 'update' );
}
sub update {
no warnings 'once'; # i use package variables below
require POE::Component::IKC::ClientLite;
my $remote = POE::Component::IKC::ClientLite::create_ikc_client(
port => $self->hub->config->notify_irc_daemon_port,
ip => $self->hub->config->notify_irc_daemon_host,
name => "Kwiki$$",
timeout => 5,
)
or die $POE::Component::IKC::ClientLite::error;
my $page = $self->pages->current;
lib/Kwiki/Notify/IRC.pm view on Meta::CPAN
exit 0;
sub bot_default
{
my ( $event, $args ) = @_[ ARG0 .. $#_ ];
err "unhandled $event";
err " - $_" foreach @$args;
return 0;
}
sub update
{
my ( $kernel, $heap, $page ) = @_[ KERNEL, HEAP, ARG0 ];
eval {
my $msg = sprintf( 'action update: %s by %s',
$page->{title}, $page->{metadata}{edit_by} );
$kernel->post( bot => ctcp => "#$_", $msg )
foreach split /,\s+/, $config->{notify_irc_server_channels};
msg sprintf( "$msg on %s", scalar localtime(time) );
};
err "update error: $@" if $@;
( run in 0.311 second using v1.01-cache-2.11-cpan-26ccb49234f )