aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xidalius.pl18
-rw-r--r--plugin/tittilate.pm2
-rw-r--r--plugin/url_title.pm6
3 files changed, 16 insertions, 10 deletions
diff --git a/idalius.pl b/idalius.pl
index 42475fc..2215b4e 100755
--- a/idalius.pl
+++ b/idalius.pl
@@ -2,7 +2,7 @@
use strict;
use warnings;
-use POSIX qw(setuid setgid);
+use POSIX qw(setuid setgid strftime);
use POE;
use POE::Kernel;
use POE::Component::IRC;
@@ -69,6 +69,12 @@ sub drop_priv {
setuid($config{uid}) or die "Failed to setuid: $!\n";
}
+sub log_info {
+ # FIXME direct to a log file instead of stdout
+ my $stamp = strftime("%Y-%m-%d %H:%M:%S %z", localtime);
+ print "$stamp | @_\n";
+}
+
sub _start {
my $heap = $_[HEAP];
my $irc = $heap->{irc};
@@ -81,7 +87,7 @@ sub irc_001 {
my $sender = $_[SENDER];
my $irc = $sender->get_heap();
- print "Connected to server ", $irc->server_name(), "\n";
+ log_info("Connected to server ", $irc->server_name());
$irc->yield( join => $_ ) for @{$config{channels}};
return;
@@ -99,7 +105,7 @@ sub irc_nick {
sub irc_kick {
my ($kicker, $channel, $kickee, $reason) = @_[ARG0 .. ARG3];
if ($kickee eq $current_nick) {
- print "I was kicked by $kicker ($reason). Rejoining now.\n";
+ log_info("I was kicked by $kicker ($reason). Rejoining now.");
$irc->yield(join => $channel);
}
return;
@@ -114,14 +120,14 @@ sub irc_public {
my $nick = ( split /!/, $who )[0];
my $channel = $where->[0];
- print("[$channel] $who: $what\n");
+ log_info("[$channel] $who: $what");
# reject ignored nicks first
return if (grep {$_ eq $nick} @{$config{ignore}});
for my $module (@plugin_list) {
my $stripped_what = strip_color(strip_formatting($what));
- my $output = $module->message($irc->nick_name, $who, $where, $what, $stripped_what);
+ my $output = $module->message(\&log_info, $irc->nick_name, $who, $where, $what, $stripped_what);
$irc->yield(privmsg => $where => $output) if $output;
}
@@ -243,6 +249,6 @@ sub _default {
push ( @output, "'$arg'" );
}
}
- print join ' ', @output, "\n";
+ log_info(join ' ', @output);
return;
}
diff --git a/plugin/tittilate.pm b/plugin/tittilate.pm
index d9d8a49..51253ec 100644
--- a/plugin/tittilate.pm
+++ b/plugin/tittilate.pm
@@ -15,7 +15,7 @@ sub configure {
}
sub message {
- my ($self, $me, $who, $where, $raw_what, $what) = @_;
+ my ($self, $logger, $me, $who, $where, $raw_what, $what) = @_;
my $gathered = "";
my @expressions = (keys %{$config{triggers}});
my $expression = join '|', @expressions;
diff --git a/plugin/url_title.pm b/plugin/url_title.pm
index f36ad6d..1c376df 100644
--- a/plugin/url_title.pm
+++ b/plugin/url_title.pm
@@ -18,7 +18,7 @@ sub configure {
sub message
{
- my ($self, $me, $who, $where, $raw_what, $what) = @_;
+ my ($self, $logger, $me, $who, $where, $raw_what, $what) = @_;
my $url;
if ($what =~ /(https?:\/\/[^ ]+)/i) {
@@ -31,12 +31,12 @@ sub message
my $response = $http->get($url);
if (!$response->{success}) {
- print "Something broke: $response->{reason}\n";
+ $logger->("Something broke: $response->{reason}");
return;
}
if (!($response->{headers}->{"content-type"} =~ m,text/html ?,)) {
- print("Not html, giving up now\n");
+ $logger->("Not html, giving up now");
return;
}