2010-03-17 07:36:54 +01:00
|
|
|
# File: Interpreter.pm
|
2010-03-22 08:33:44 +01:00
|
|
|
# Author: pragma_
|
2010-03-17 07:36:54 +01:00
|
|
|
#
|
2010-03-22 08:33:44 +01:00
|
|
|
# Purpose:
|
2010-03-17 07:36:54 +01:00
|
|
|
|
|
|
|
package PBot::Interpreter;
|
|
|
|
|
|
|
|
use warnings;
|
|
|
|
use strict;
|
|
|
|
|
2010-03-22 08:33:44 +01:00
|
|
|
use base 'PBot::Registerable';
|
|
|
|
|
2010-04-13 06:17:54 +02:00
|
|
|
use LWP::UserAgent;
|
2010-03-22 08:33:44 +01:00
|
|
|
use Carp ();
|
|
|
|
|
|
|
|
sub new {
|
|
|
|
if(ref($_[1]) eq 'HASH') {
|
2014-05-19 23:34:24 +02:00
|
|
|
Carp::croak("Options to " . __FILE__ . " should be key/value pairs, not hash reference");
|
2010-03-22 08:33:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
my ($class, %conf) = @_;
|
|
|
|
my $self = bless {}, $class;
|
|
|
|
$self->initialize(%conf);
|
|
|
|
return $self;
|
2010-03-17 07:36:54 +01:00
|
|
|
}
|
|
|
|
|
2010-03-22 08:33:44 +01:00
|
|
|
sub initialize {
|
|
|
|
my ($self, %conf) = @_;
|
|
|
|
|
|
|
|
$self->SUPER::initialize(%conf);
|
2010-03-17 07:36:54 +01:00
|
|
|
|
2014-05-19 23:34:24 +02:00
|
|
|
$self->{pbot} = delete $conf{pbot} // Carp::croak("Missing pbot reference to " . __FILE__);
|
2010-04-13 06:17:54 +02:00
|
|
|
|
2014-05-19 23:34:24 +02:00
|
|
|
$self->{pbot}->{registry}->add_default('text', 'general', 'show_url_titles', $conf{show_url_titles} // 1);
|
|
|
|
$self->{pbot}->{registry}->add_default('array', 'general', 'show_url_titles_channels', $conf{show_url_titles_channels} // '.*');
|
|
|
|
$self->{pbot}->{registry}->add_default('array', 'general', 'show_url_titles_ignore_channels', $conf{show_url_titles_ignore_channels} // 'none');
|
|
|
|
$self->{pbot}->{registry}->add_default('text', 'general', 'compile_blocks', $conf{compile_blocks} // 1);
|
|
|
|
$self->{pbot}->{registry}->add_default('array', 'general', 'compile_blocks_channels', $conf{compile_blocks_channels} // '.*');
|
|
|
|
$self->{pbot}->{registry}->add_default('array', 'general', 'compile_blocks_ignore_channels', $conf{compile_blocks_ignore_channels} // 'none');
|
2014-05-31 03:05:47 +02:00
|
|
|
$self->{pbot}->{registry}->add_default('text', 'interpreter', 'max_recursion', 10);
|
2012-07-22 21:22:30 +02:00
|
|
|
}
|
2010-04-13 06:17:54 +02:00
|
|
|
|
2010-03-17 07:36:54 +01:00
|
|
|
sub process_line {
|
2010-03-22 08:33:44 +01:00
|
|
|
my $self = shift;
|
2010-03-17 07:36:54 +01:00
|
|
|
my ($from, $nick, $user, $host, $text) = @_;
|
2012-07-22 21:22:30 +02:00
|
|
|
|
2014-03-14 11:05:11 +01:00
|
|
|
my $command;
|
2012-07-22 21:22:30 +02:00
|
|
|
my $has_url;
|
|
|
|
my $has_code;
|
|
|
|
my $nick_override;
|
2014-05-17 22:08:19 +02:00
|
|
|
my $mynick = $self->{pbot}->{registry}->get_value('irc', 'botnick');
|
2010-03-17 07:36:54 +01:00
|
|
|
|
|
|
|
$from = lc $from if defined $from;
|
|
|
|
|
2014-05-19 23:34:24 +02:00
|
|
|
my $pbot = $self->{pbot};
|
2010-03-22 08:33:44 +01:00
|
|
|
|
2014-05-13 12:15:52 +02:00
|
|
|
my $message_account = $pbot->{messagehistory}->get_message_account($nick, $user, $host);
|
|
|
|
$pbot->{messagehistory}->add_message($message_account, "$nick!$user\@$host", $from, $text, $pbot->{messagehistory}->{MSG_CHAT});
|
|
|
|
|
2014-05-19 04:42:18 +02:00
|
|
|
$pbot->{antiflood}->check_flood($from, $nick, $user, $host, $text,
|
|
|
|
$pbot->{registry}->get_value('antiflood', 'chat_flood_threshold'),
|
|
|
|
$pbot->{registry}->get_value('antiflood', 'chat_flood_time_threshold'),
|
|
|
|
$pbot->{messagehistory}->{MSG_CHAT}) if defined $from;
|
2010-03-17 07:36:54 +01:00
|
|
|
|
2013-07-24 14:33:19 +02:00
|
|
|
$text =~ s/^\s+//;
|
|
|
|
$text =~ s/\s+$//;
|
2012-07-22 21:22:30 +02:00
|
|
|
my $preserve_whitespace = 0;
|
|
|
|
|
2013-07-24 14:33:19 +02:00
|
|
|
my $cmd_text = $text;
|
|
|
|
$cmd_text =~ s/^\/me\s+//;
|
|
|
|
|
2014-05-17 22:08:19 +02:00
|
|
|
my $bot_trigger = $pbot->{registry}->get_value('general', 'trigger');
|
|
|
|
|
|
|
|
if($cmd_text =~ /^$bot_trigger?\s*{\s*(.*)\s*}\s*$/) {
|
2014-02-25 04:47:12 +01:00
|
|
|
$has_code = $1 if length $1;
|
|
|
|
$preserve_whitespace = 1;
|
2014-05-17 22:08:19 +02:00
|
|
|
} elsif($cmd_text =~ /^\Q$bot_trigger\E(.*)$/) {
|
2012-08-24 00:50:07 +02:00
|
|
|
$command = $1;
|
2013-07-24 14:33:19 +02:00
|
|
|
} elsif($cmd_text =~ /^.?$mynick.?\s+(.*?)$/i) {
|
2012-08-24 00:50:07 +02:00
|
|
|
$command = $1;
|
2013-07-24 14:33:19 +02:00
|
|
|
} elsif($cmd_text =~ /^(.*?),?\s+$mynick[?!.]*$/i) {
|
2012-08-24 00:50:07 +02:00
|
|
|
$command = $1;
|
2013-07-24 14:33:19 +02:00
|
|
|
} elsif($cmd_text =~ /https?:\/\/([^\s]+)/i) {
|
2010-03-17 07:36:54 +01:00
|
|
|
$has_url = $1;
|
2013-07-24 14:33:19 +02:00
|
|
|
} elsif($cmd_text =~ /^\s*([^,:\(\)\+\*\/ ]+)[,:]*\s*{\s*(.*)\s*}\s*$/) {
|
2012-07-22 21:22:30 +02:00
|
|
|
$nick_override = $1;
|
|
|
|
$has_code = $2 if length $2 and $nick_override ne 'enum' and $nick_override ne 'struct';
|
|
|
|
$preserve_whitespace = 1;
|
2010-03-17 07:36:54 +01:00
|
|
|
}
|
|
|
|
|
2012-07-22 21:22:30 +02:00
|
|
|
if(defined $command || defined $has_url || defined $has_code) {
|
|
|
|
if((defined $command && $command !~ /^login/i) || defined $has_url || defined $has_code) {
|
2014-05-18 22:09:05 +02:00
|
|
|
if(defined $from && $pbot->{ignorelist}->check_ignore($nick, $user, $host, $from) && not $pbot->{admins}->loggedin($from, "$nick!$user\@$host")) {
|
2010-03-22 08:33:44 +01:00
|
|
|
# ignored hostmask
|
2014-05-18 22:09:05 +02:00
|
|
|
$pbot->{logger}->log("ignored text: [$from][$nick!$user\@$host\[$text\]\n");
|
2010-03-22 08:33:44 +01:00
|
|
|
return;
|
2010-03-17 07:36:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-22 21:22:30 +02:00
|
|
|
if(defined $has_url) {
|
2014-05-19 23:34:24 +02:00
|
|
|
if($self->{pbot}->{registry}->get_value('general', 'show_url_titles')
|
|
|
|
and not grep { $from =~ /$_/i } $self->{pbot}->{registry}->get_value('general', 'show_url_titles_ignore_channels')
|
|
|
|
and grep { $from =~ /$_/i } $self->{pbot}->{registry}->get_value('general', 'show_url_titles_channels')) {
|
|
|
|
$self->{pbot}->{factoids}->{factoidmodulelauncher}->execute_module($from, undef, $nick, $user, $host, $text, "title", "$nick http://$has_url", $preserve_whitespace);
|
|
|
|
}
|
2012-07-22 21:22:30 +02:00
|
|
|
} elsif(defined $has_code) {
|
2014-05-19 23:34:24 +02:00
|
|
|
if($self->{pbot}->{registry}->get_value('general', 'compile_blocks')
|
|
|
|
and not grep { $from =~ /$_/i } $self->{pbot}->{registry}->get_value('general', 'compile_blocks_ignore_channels')
|
|
|
|
and grep { $from =~ /$_/i } $self->{pbot}->{registry}->get_value('general', 'compile_blocks_channels')) {
|
|
|
|
$self->{pbot}->{factoids}->{factoidmodulelauncher}->execute_module($from, undef, $nick, $user, $host, $text, "compiler_block", (defined $nick_override ? $nick_override : $nick) . " $from $has_code }", $preserve_whitespace);
|
|
|
|
}
|
2012-07-22 21:22:30 +02:00
|
|
|
} else {
|
2014-03-14 11:05:11 +01:00
|
|
|
$self->handle_result($from, $nick, $user, $host, $text, $command, $self->interpret($from, $nick, $user, $host, 1, $command), 1, $preserve_whitespace);
|
2010-04-17 21:22:22 +02:00
|
|
|
}
|
2014-03-14 11:05:11 +01:00
|
|
|
}
|
|
|
|
}
|
2010-03-17 07:36:54 +01:00
|
|
|
|
2014-03-15 02:53:33 +01:00
|
|
|
sub truncate_result {
|
|
|
|
my ($self, $from, $nick, $text, $original_result, $result, $paste) = @_;
|
2014-05-17 22:08:19 +02:00
|
|
|
my $max_msg_len = $self->{pbot}->{registry}->get_value('irc', 'max_msg_len');
|
2014-03-15 02:53:33 +01:00
|
|
|
|
2014-05-17 22:08:19 +02:00
|
|
|
if(length $result > $max_msg_len) {
|
2014-03-15 02:53:33 +01:00
|
|
|
my $link;
|
|
|
|
if($paste) {
|
|
|
|
$link = paste_sprunge("[" . (defined $from ? $from : "stdin") . "] <$nick> $text\n\n$original_result");
|
|
|
|
} else {
|
|
|
|
$link = 'undef';
|
|
|
|
}
|
|
|
|
|
|
|
|
my $trunc = "... [truncated; see $link for full text.]";
|
2014-05-18 22:09:05 +02:00
|
|
|
$self->{pbot}->{logger}->log("Message truncated -- pasted to $link\n") if $paste;
|
2014-03-15 02:53:33 +01:00
|
|
|
|
2014-05-17 22:08:19 +02:00
|
|
|
my $trunc_len = length $result < $max_msg_len ? length $result : $max_msg_len;
|
2014-03-15 02:53:33 +01:00
|
|
|
$result = substr($result, 0, $trunc_len);
|
|
|
|
substr($result, $trunc_len - length $trunc) = $trunc;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
2014-03-14 11:05:11 +01:00
|
|
|
sub handle_result {
|
|
|
|
my ($self, $from, $nick, $user, $host, $text, $command, $result, $checkflood, $preserve_whitespace) = @_;
|
2014-05-17 22:08:19 +02:00
|
|
|
my ($pbot, $mynick) = ($self->{pbot}, $self->{pbot}->{registry}->get_value('irc', 'botnick'));
|
2012-07-22 21:22:30 +02:00
|
|
|
|
2014-03-14 11:05:11 +01:00
|
|
|
if(not defined $result or length $result == 0) {
|
|
|
|
return;
|
|
|
|
}
|
2012-07-22 21:22:30 +02:00
|
|
|
|
2014-03-14 11:05:11 +01:00
|
|
|
my $original_result = $result;
|
2010-03-17 07:36:54 +01:00
|
|
|
|
2014-03-14 11:05:11 +01:00
|
|
|
if($preserve_whitespace == 0 && defined $command) {
|
|
|
|
my ($cmd, $args) = split / /, $command, 2;
|
2014-05-18 22:09:05 +02:00
|
|
|
my ($chan, $trigger) = $self->{pbot}->{factoids}->find_factoid($from, $cmd, $args, 0, 1);
|
2014-03-14 11:05:11 +01:00
|
|
|
if(defined $trigger) {
|
2014-05-18 22:09:05 +02:00
|
|
|
$preserve_whitespace = $self->{pbot}->{factoids}->{factoids}->hash->{$chan}->{$trigger}->{preserve_whitespace};
|
2014-03-14 11:05:11 +01:00
|
|
|
$preserve_whitespace = 0 if not defined $preserve_whitespace;
|
2010-03-17 07:36:54 +01:00
|
|
|
}
|
2014-03-14 11:05:11 +01:00
|
|
|
}
|
2013-10-22 20:57:08 +02:00
|
|
|
|
2014-08-05 00:48:32 +02:00
|
|
|
my $preserve_newlines = $self->{pbot}->{registry}->get_value($from, 'preserve_newlines');
|
|
|
|
|
|
|
|
$result =~ s/[\n\r]/ /g unless $preserve_newlines;
|
2014-08-06 01:11:51 +02:00
|
|
|
$result =~ s/[ \t]+/ /g unless $preserve_whitespace;
|
2014-08-05 00:48:32 +02:00
|
|
|
|
2014-08-06 01:15:11 +02:00
|
|
|
my $max_lines = $self->{pbot}->{registry}->get_value($from, 'max_newlines');
|
|
|
|
$max_lines = 4 if not defined $max_lines;
|
2014-08-05 00:48:32 +02:00
|
|
|
my $lines = 0;
|
2014-08-06 01:15:11 +02:00
|
|
|
|
2014-08-11 09:32:24 +02:00
|
|
|
my $stripped_line;
|
|
|
|
foreach my $line (split /[\n\r]+/, $result) {
|
|
|
|
$stripped_line = $line;
|
|
|
|
$stripped_line =~ s/^\s+//;
|
|
|
|
$stripped_line =~ s/\s+$//;
|
|
|
|
next if not length $stripped_line;
|
|
|
|
|
2014-08-06 01:15:11 +02:00
|
|
|
if (++$lines >= $max_lines) {
|
2014-08-06 01:11:51 +02:00
|
|
|
my $link = paste_sprunge("[" . (defined $from ? $from : "stdin") . "] <$nick> $text\n\n$original_result");
|
2014-08-06 01:15:11 +02:00
|
|
|
$pbot->{conn}->privmsg($from, "And that's all I have to say about that. See $link for full text.");
|
2014-08-05 00:48:32 +02:00
|
|
|
last;
|
2014-03-14 11:05:11 +01:00
|
|
|
}
|
2014-08-05 00:48:32 +02:00
|
|
|
|
|
|
|
if ($preserve_newlines) {
|
|
|
|
$line = $self->truncate_result($from, $nick, $text, $line, $line, 1);
|
|
|
|
} else {
|
|
|
|
$line = $self->truncate_result($from, $nick, $text, $original_result, $line, 1);
|
2014-03-14 11:05:11 +01:00
|
|
|
}
|
2014-08-05 00:48:32 +02:00
|
|
|
|
|
|
|
$pbot->{logger}->log("Final result: [$line]\n");
|
|
|
|
|
|
|
|
if($line =~ s/^\/say\s+//i) {
|
|
|
|
$pbot->{conn}->privmsg($from, $line) if defined $from && $from !~ /\Q$mynick\E/i;
|
|
|
|
$pbot->{antiflood}->check_flood($from, $mynick, $pbot->{registry}->get_value('irc', 'username'), 'localhost', $line, 0, 0, 0) if $checkflood;
|
|
|
|
} elsif($line =~ s/^\/me\s+//i) {
|
|
|
|
$pbot->{conn}->me($from, $line) if defined $from && $from !~ /\Q$mynick\E/i;
|
|
|
|
$pbot->{antiflood}->check_flood($from, $mynick, $pbot->{registry}->get_value('irc', 'username'), 'localhost', '/me ' . $line, 0, 0, 0) if $checkflood;
|
|
|
|
} elsif($line =~ s/^\/msg\s+([^\s]+)\s+//i) {
|
|
|
|
my $to = $1;
|
|
|
|
if($to =~ /,/) {
|
|
|
|
$pbot->{logger}->log("[HACK] Possible HACK ATTEMPT /msg multiple users: [$nick!$user\@$host] [$command] [$line]\n");
|
|
|
|
}
|
|
|
|
elsif($to =~ /.*serv$/i) {
|
|
|
|
$pbot->{logger}->log("[HACK] Possible HACK ATTEMPT /msg *serv: [$nick!$user\@$host] [$command] [$line]\n");
|
|
|
|
}
|
|
|
|
elsif($line =~ s/^\/me\s+//i) {
|
|
|
|
$pbot->{conn}->me($to, $line) if $to !~ /\Q$mynick\E/i;
|
|
|
|
$pbot->{antiflood}->check_flood($to, $mynick, $pbot->{registry}->get_value('irc', 'username'), 'localhost', '/me ' . $line, 0, 0, 0) if $checkflood;
|
|
|
|
} else {
|
|
|
|
$line =~ s/^\/say\s+//i;
|
|
|
|
$pbot->{conn}->privmsg($to, $line) if $to !~ /\Q$mynick\E/i;
|
|
|
|
$pbot->{antiflood}->check_flood($to, $mynick, $pbot->{registry}->get_value('irc', 'username'), 'localhost', $line, 0, 0, 0) if $checkflood;
|
|
|
|
}
|
2014-03-14 11:05:11 +01:00
|
|
|
} else {
|
2014-08-05 00:48:32 +02:00
|
|
|
$pbot->{conn}->privmsg($from, $line) if defined $from && $from !~ /\Q$mynick\E/i;
|
|
|
|
$pbot->{antiflood}->check_flood($from, $mynick, $pbot->{registry}->get_value('irc', 'username'), 'localhost', $line, 0, 0, 0) if $checkflood;
|
2010-03-22 08:33:44 +01:00
|
|
|
}
|
2010-03-17 07:36:54 +01:00
|
|
|
}
|
2014-05-18 22:09:05 +02:00
|
|
|
$pbot->{logger}->log("---------------------------------------------\n");
|
2010-03-17 07:36:54 +01:00
|
|
|
}
|
|
|
|
|
2010-03-22 08:33:44 +01:00
|
|
|
sub interpret {
|
|
|
|
my $self = shift;
|
2012-08-24 00:50:07 +02:00
|
|
|
my ($from, $nick, $user, $host, $count, $command, $tonick) = @_;
|
|
|
|
my ($keyword, $arguments) = ("", "");
|
2010-03-17 07:36:54 +01:00
|
|
|
my $text;
|
2014-05-19 23:34:24 +02:00
|
|
|
my $pbot = $self->{pbot};
|
2010-03-17 07:36:54 +01:00
|
|
|
|
2014-05-18 22:09:05 +02:00
|
|
|
$pbot->{logger}->log("=== Enter interpret_command: [" . (defined $from ? $from : "(undef)") . "][$nick!$user\@$host][$count][$command]\n");
|
2010-03-17 07:36:54 +01:00
|
|
|
|
2014-05-31 03:05:47 +02:00
|
|
|
return "Too many levels of recursion, aborted." if(++$count > $self->{pbot}->{registry}->get_value('interpreter', 'max_recursion'));
|
2010-03-17 07:36:54 +01:00
|
|
|
|
|
|
|
if(not defined $nick || not defined $user || not defined $host ||
|
|
|
|
not defined $command) {
|
2014-05-18 22:09:05 +02:00
|
|
|
$pbot->{logger}->log("Error 1, bad parameters to interpret_command\n");
|
2010-03-22 08:33:44 +01:00
|
|
|
return undef;
|
2010-03-17 07:36:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if($command =~ /^tell\s+(.{1,20})\s+about\s+(.*?)\s+(.*)$/i)
|
|
|
|
{
|
|
|
|
($keyword, $arguments, $tonick) = ($2, $3, $1);
|
2012-09-06 12:09:44 +02:00
|
|
|
} elsif($command =~ /^tell\s+(.{1,20})\s+about\s+(.*)$/i) {
|
2010-03-17 07:36:54 +01:00
|
|
|
($keyword, $tonick) = ($2, $1);
|
|
|
|
} elsif($command =~ /^(.*?)\s+(.*)$/) {
|
|
|
|
($keyword, $arguments) = ($1, $2);
|
|
|
|
} else {
|
2012-08-24 00:50:07 +02:00
|
|
|
$keyword = $command;
|
|
|
|
}
|
|
|
|
|
2014-04-29 06:05:20 +02:00
|
|
|
if($keyword ne "factadd"
|
|
|
|
and $keyword ne "add"
|
|
|
|
and $keyword ne "factset"
|
|
|
|
and $keyword ne "factchange"
|
|
|
|
and $keyword ne "change"
|
|
|
|
and $keyword ne "msg") {
|
2012-08-24 00:50:07 +02:00
|
|
|
$keyword =~ s/(\w+)([?!.]+)$/$1/;
|
|
|
|
$arguments =~ s/(\w+)([?!.]+)$/$1/;
|
|
|
|
$arguments =~ s/(?<![\w\/\-])me\b/$nick/gi if defined $arguments;
|
2010-03-17 07:36:54 +01:00
|
|
|
}
|
|
|
|
|
2010-06-19 19:37:16 +02:00
|
|
|
if(defined $arguments && $arguments =~ m/^(your|him|her|its|it|them|their)(self|selves)$/i) {
|
2010-03-17 07:36:54 +01:00
|
|
|
return "Why would I want to do that to myself?";
|
|
|
|
}
|
|
|
|
|
|
|
|
if(not defined $keyword) {
|
2014-05-18 22:09:05 +02:00
|
|
|
$pbot->{logger}->log("Error 2, no keyword\n");
|
2010-03-22 08:33:44 +01:00
|
|
|
return undef;
|
2010-03-17 07:36:54 +01:00
|
|
|
}
|
|
|
|
|
2010-03-22 08:33:44 +01:00
|
|
|
return $self->SUPER::execute_all($from, $nick, $user, $host, $count, $keyword, $arguments, $tonick);
|
|
|
|
}
|
2010-03-17 07:36:54 +01:00
|
|
|
|
2014-05-19 23:34:24 +02:00
|
|
|
sub paste_codepad {
|
|
|
|
my $text = join(' ', @_);
|
|
|
|
|
|
|
|
$text =~ s/(.{120})\s/$1\n/g;
|
|
|
|
|
|
|
|
my $ua = LWP::UserAgent->new();
|
|
|
|
$ua->agent("Mozilla/5.0");
|
|
|
|
push @{ $ua->requests_redirectable }, 'POST';
|
|
|
|
|
|
|
|
my %post = ( 'lang' => 'Plain Text', 'code' => $text, 'private' => 'True', 'submit' => 'Submit' );
|
|
|
|
my $response = $ua->post("http://codepad.org", \%post);
|
|
|
|
|
|
|
|
if(not $response->is_success) {
|
|
|
|
return $response->status_line;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $response->request->uri;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub paste_sprunge {
|
|
|
|
my $text = join(' ', @_);
|
|
|
|
|
|
|
|
$text =~ s/(.{120})\s/$1\n/g;
|
|
|
|
|
|
|
|
my $ua = LWP::UserAgent->new();
|
|
|
|
$ua->agent("Mozilla/5.0");
|
|
|
|
$ua->requests_redirectable([ ]);
|
|
|
|
|
|
|
|
my %post = ( 'sprunge' => $text, 'submit' => 'Submit' );
|
|
|
|
my $response = $ua->post("http://sprunge.us", \%post);
|
|
|
|
|
|
|
|
if(not $response->is_success) {
|
|
|
|
return $response->status_line;
|
|
|
|
}
|
|
|
|
|
|
|
|
my $result = $response->content;
|
|
|
|
$result =~ s/^\s+//;
|
|
|
|
$result =~ s/\s+$//;
|
|
|
|
return $result;
|
2010-03-17 07:36:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
1;
|