mirror of
https://github.com/perlbot/perlbuut
synced 2025-06-07 15:55:42 -04:00
Clean up output, also add new role for the new pastebin
This commit is contained in:
parent
3e3820551e
commit
a0b2f7c715
3 changed files with 79 additions and 7 deletions
|
@ -25,6 +25,10 @@ http_plugin_port 1092
|
|||
hostname erxz.com:10081
|
||||
alias_url = http://erxz.com/bb3pb
|
||||
</pastebot>
|
||||
|
||||
<evalpastebin>
|
||||
enabled yes
|
||||
</evalpastebin>
|
||||
</Roles>
|
||||
|
||||
# Change this to be bot specific?
|
||||
|
@ -75,7 +79,7 @@ http_plugin_port 1092
|
|||
root_mask p3m/member/simcop2387
|
||||
</bot>
|
||||
|
||||
<bot perlbot>
|
||||
<bot perlbot-magnet>
|
||||
channel \#freenode-perl-cabal
|
||||
channel \#perl-help
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ sub new {
|
|||
sub yield {
|
||||
my ( $self, $event, @args ) = @_;
|
||||
|
||||
warn "YIELD CALLED: $event\n";
|
||||
# warn "YIELD CALLED: $event\n";
|
||||
|
||||
return POE::Kernel->post( $self->{session}, $event, @args );
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ sub yield {
|
|||
sub call {
|
||||
my ( $self, $event, @args ) = @_;
|
||||
|
||||
warn "CALL CALLED: $event\n";
|
||||
# warn "CALL CALLED: $event\n";
|
||||
|
||||
return POE::Kernel->call( $self->{session}, $event, @args );
|
||||
}
|
||||
|
@ -478,7 +478,7 @@ sub handle_said_queue {
|
|||
return unless $queue and @$queue;
|
||||
|
||||
while( defined( my $said = shift @$queue ) ) {
|
||||
warn "Queuing $said\n";
|
||||
# warn "Queuing $said\n";
|
||||
|
||||
for( @$children ) {
|
||||
warn "Checking ", $_->{wheel}->PID, ": $_->{queue}";
|
||||
|
@ -601,10 +601,10 @@ sub child_output {
|
|||
my( $self, $kernel, $output, $child_id ) = @_[OBJECT,KERNEL,ARG0,ARG1];
|
||||
my( $said, $text ) = @$output;
|
||||
|
||||
warn "Got some child output! $text\n";
|
||||
# warn "Got some child output! $text\n";
|
||||
|
||||
my $child = $self->{children}->{$child_id};
|
||||
warn "Deleting child queue: $child_id, $child->{queue}";
|
||||
# warn "Deleting child queue: $child_id, $child->{queue}";
|
||||
$child->{queue} = undef;
|
||||
|
||||
$self->yield('handle_said_queue');
|
||||
|
@ -639,7 +639,7 @@ sub child_err {
|
|||
|
||||
return unless $err_output =~ /\S/;
|
||||
|
||||
warn "\n\tChild $child_id: $err_output\n";
|
||||
# warn "\n\tChild $child_id: $err_output\n";
|
||||
}
|
||||
|
||||
sub child_fail {
|
||||
|
|
68
lib/Bot/BB3/Roles/Evalpastebin.pm
Normal file
68
lib/Bot/BB3/Roles/Evalpastebin.pm
Normal file
|
@ -0,0 +1,68 @@
|
|||
package Bot::BB3::Roles::Evalpastebin;
|
||||
|
||||
use POE;
|
||||
use POE::Component::Server::TCP;
|
||||
use strict;
|
||||
use Data::Dumper;
|
||||
use JSON::MaybeXS;
|
||||
|
||||
sub new {
|
||||
my( $class, $conf, $pm ) = @_;
|
||||
|
||||
my $self = bless { conf => $conf, pm => $pm }, $class;
|
||||
|
||||
$self->{session} = POE::Session->create(
|
||||
object_states => [
|
||||
$self => [ qw/_start receive_paste/ ]
|
||||
]
|
||||
);
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub _start {
|
||||
my( $self, $kernel ) = @_[OBJECT,KERNEL];
|
||||
my $conf = $self->{conf};
|
||||
|
||||
# TODO setup TCP server.
|
||||
$self->{server} = POE::Component::Server::TCP->new(
|
||||
Port => 1784,
|
||||
Address =>'127.0.0.1',
|
||||
ClientFilter => "POE::Filter::Line",
|
||||
ClientInput => \&receive_paste,
|
||||
);
|
||||
|
||||
$kernel->alias_set( "evalpastebin_role" );
|
||||
$kernel->sig("DIE" => 'sig_DIE' );
|
||||
}
|
||||
|
||||
sub receive_paste {
|
||||
my ($kernel, $line) = @_[KERNEL, ARG0];
|
||||
|
||||
chomp $line;
|
||||
|
||||
if ($line eq 'GET_CHANNELS') {
|
||||
my $channel_list = $kernel->call("Bot::BB3::Roles::IRC", "channel_list");
|
||||
$_[HEAP]{client}->put(encode_json($channel_list));
|
||||
} else {
|
||||
my ($alert_channel, $link, $who, $summary) = split(/\x1E/, $line);
|
||||
|
||||
if( $alert_channel !~ /^\s*---/ ) { # Ignore things like "---irc.freenode, skip server names
|
||||
my($server,$nick,$channel) = split /:/,$alert_channel,3;
|
||||
|
||||
$_[KERNEL]->post( "Bot::BB3::Roles::IRC",
|
||||
external_message =>
|
||||
$server,
|
||||
$nick,
|
||||
$channel,
|
||||
"$who pasted a new file at $link - $summary"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub sig_DIE {
|
||||
# Do nothing, we're ignoring fatal errors from our child, poco-server-simplehttp. I think we don't need to respawn them.
|
||||
}
|
||||
|
||||
1;
|
Loading…
Add table
Reference in a new issue