Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' of github.com:tadzik/a8bot

  • Loading branch information...
commit dc6d9c2227d00ecde6f4b97e3657d21238ab5d80 2 parents 5a0bae0 + 218daf5
@lessmian lessmian authored
View
2  README
@@ -1,5 +1,3 @@
-Needs Perl compiled with threads
-
Required modules:
Moose
MooseX::NonMoose
View
4 a8bot.pm
@@ -82,6 +82,10 @@ sub BUILD {
);
}
},
+ error => sub {
+ my (undef, $code, $message, $ircmsg) = @_;
+ $self->log("Error $code: $message");
+ },
publicmsg => sub {
my ($client, $channel, $params) = @_;
foreach my $plugin ($self->list_plugins) {
View
5 a8bot/Plugin.pm
@@ -1,6 +1,7 @@
package a8bot::Plugin;
use feature ':5.10';
use lib 'plugins';
+use Module::Load;
use Moose;
has 'bot' => (
@@ -48,7 +49,7 @@ has '_registered' => (
sub BUILD {
my $self = shift;
- require $self->plugin . '.pm';
+ load $self->plugin;
my $events = $self->plugin->init;
$self->_disconnect($events->{disconnect} // sub {});
$self->_publicmsg($events->{publicmsg} // sub {});
@@ -76,7 +77,7 @@ sub publicmsg {
);
if (ref $resp eq 'ARRAY') {
$self->bot->send_srv(@$resp);
- } elsif (defined $resp) {
+ } elsif (defined $resp and $resp ne '') {
$self->bot->send_srv(PRIVMSG => $channel, $resp);
}
}
View
1  plugins/Ping.pm
@@ -13,6 +13,7 @@ sub pubmsg {
if ($data->{msg} =~ /^$bot->{nick}:?,? ping$/) {
return [PRIVMSG => $data->{channel}, "$data->{nick}: pong"];
}
+ return undef;
}
1;
View
6 plugins/Powiedz.pm
@@ -26,7 +26,11 @@ sub pubmsg {
}
$db->remove($data->{nick});
}
- return $resp;
+ if ($resp ne '') {
+ return $resp;
+ } else {
+ return undef;
+ }
}
1;
View
10 plugins/WebTitle.pm
@@ -10,13 +10,11 @@ sub pubmsg {
if ($data->{msg} =~ /(http:\/\/[^ ]+)/) {
$ua->max_size(1024);
my $site = get($1);
- my ($title) = $site =~ /<title>([^<]+)<\/title>/;
- if ($title) {
- return "[ $title ]";
- } else {
- return undef;
- }
+ my ($title) = $site =~ /<title>([^<]+)<\/title>/i;
+ $title =~ s/\n/ /g;
+ return "[ $title ]" if $title;
}
+ return undef;
}
1;
Please sign in to comment.
Something went wrong with that request. Please try again.