fix crashes relating to unicode characters
This commit is contained in:
parent
f7f6583008
commit
67d4383081
|
@ -15,6 +15,7 @@ use MarkovBot::Ignore;
|
||||||
use MarkovBot::Commands;
|
use MarkovBot::Commands;
|
||||||
use MarkovBot::MarkovChain;
|
use MarkovBot::MarkovChain;
|
||||||
use MarkovBot::Redis;
|
use MarkovBot::Redis;
|
||||||
|
use Encode qw(encode decode);
|
||||||
|
|
||||||
sub said {
|
sub said {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
@ -30,7 +31,7 @@ sub said {
|
||||||
# Intercept commands
|
# Intercept commands
|
||||||
if ($msg->{body} =~ m/^$command_char.+/) {
|
if ($msg->{body} =~ m/^$command_char.+/) {
|
||||||
|
|
||||||
my $command = $msg->{body};
|
my $command = encode("UTF-8", $msg->{body});
|
||||||
my @command = split(" ", $command);
|
my @command = split(" ", $command);
|
||||||
my $bare = $command[0];
|
my $bare = $command[0];
|
||||||
$bare =~ s/^$command_char//;
|
$bare =~ s/^$command_char//;
|
||||||
|
@ -39,7 +40,7 @@ sub said {
|
||||||
|
|
||||||
if (defined $subs{$bare}) {
|
if (defined $subs{$bare}) {
|
||||||
my $ret = $subs{$bare}->(\@command);
|
my $ret = $subs{$bare}->(\@command);
|
||||||
$self->say( channel => config("irc_channel"), body => $ret ) unless $ret eq "___null___";
|
$self->say( channel => config("irc_channel"), body => decode("UTF-8", $ret) ) unless $ret eq "___null___";
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue