1
0
Fork 0
mirror of https://github.com/perlbot/perlbuut synced 2025-06-07 16:45:40 -04:00

Fix unicode in compose, and other fixes

This commit is contained in:
Ryan Voots 2019-03-15 00:34:20 -04:00
parent 32c00d1c9b
commit 516299d413
2 changed files with 4 additions and 3 deletions

View file

@ -1,6 +1,7 @@
package Bot::BB3::Plugin::Compose;
use strict;
no warnings 'void';
use Encode qw/encode decode/;
sub new {
my( $class ) = @_;
my $self = bless {}, $class;
@ -26,7 +27,7 @@ sub command {
sub compose {
my($said, $pm) = @_;
my $str = $said->{body};
my $str = decode 'utf8', $said->{body};
$said->{recursion} = 50 unless defined $said->{recursion};
$str =~ /\A\s*((\S).*(\S))\s*\z/s or
@ -93,7 +94,7 @@ sub runplugin {
my $plugin = $pm->get_plugin( $cmd, $said )
or return( 0, "Compose failed to find a plugin named: $cmd" );
local $said->{body} = $body;
local $said->{body} = encode 'utf8', $body;
local $said->{recommended_args} = [ split /\s+/, $body ];
local $said->{command_match} = $cmd;

View file

@ -124,7 +124,7 @@ sub command {
my $c=$1;
my $v=$2;
my $all = $3;
$code = "use warnings; ".$code if ($c =~ /w/ && ($v>=6 || !defined $v || $all));
$code = "use warnings; no warnings 'experimental';".$code if ($c =~ /w/ && ($v>=6 || !defined $v || $all));
$code = '$^W=1;'.$code if ($c =~ /w/ && (defined $v && $v < 6 && !$all));
$code = "use strict; ".$code if ($c =~ /s/);
$code = "use ojo; ".$code if ($c =~ /m/);