mirror of
https://github.com/perlbot/perlbuut
synced 2025-06-07 18:45:42 -04:00
Fix unicode in compose, and other fixes
This commit is contained in:
parent
32c00d1c9b
commit
516299d413
2 changed files with 4 additions and 3 deletions
|
@ -1,6 +1,7 @@
|
||||||
package Bot::BB3::Plugin::Compose;
|
package Bot::BB3::Plugin::Compose;
|
||||||
use strict;
|
use strict;
|
||||||
no warnings 'void';
|
no warnings 'void';
|
||||||
|
use Encode qw/encode decode/;
|
||||||
sub new {
|
sub new {
|
||||||
my( $class ) = @_;
|
my( $class ) = @_;
|
||||||
my $self = bless {}, $class;
|
my $self = bless {}, $class;
|
||||||
|
@ -26,7 +27,7 @@ sub command {
|
||||||
|
|
||||||
sub compose {
|
sub compose {
|
||||||
my($said, $pm) = @_;
|
my($said, $pm) = @_;
|
||||||
my $str = $said->{body};
|
my $str = decode 'utf8', $said->{body};
|
||||||
$said->{recursion} = 50 unless defined $said->{recursion};
|
$said->{recursion} = 50 unless defined $said->{recursion};
|
||||||
|
|
||||||
$str =~ /\A\s*((\S).*(\S))\s*\z/s or
|
$str =~ /\A\s*((\S).*(\S))\s*\z/s or
|
||||||
|
@ -93,7 +94,7 @@ sub runplugin {
|
||||||
my $plugin = $pm->get_plugin( $cmd, $said )
|
my $plugin = $pm->get_plugin( $cmd, $said )
|
||||||
or return( 0, "Compose failed to find a plugin named: $cmd" );
|
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->{recommended_args} = [ split /\s+/, $body ];
|
||||||
local $said->{command_match} = $cmd;
|
local $said->{command_match} = $cmd;
|
||||||
|
|
||||||
|
|
|
@ -124,7 +124,7 @@ sub command {
|
||||||
my $c=$1;
|
my $c=$1;
|
||||||
my $v=$2;
|
my $v=$2;
|
||||||
my $all = $3;
|
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 = '$^W=1;'.$code if ($c =~ /w/ && (defined $v && $v < 6 && !$all));
|
||||||
$code = "use strict; ".$code if ($c =~ /s/);
|
$code = "use strict; ".$code if ($c =~ /s/);
|
||||||
$code = "use ojo; ".$code if ($c =~ /m/);
|
$code = "use ojo; ".$code if ($c =~ /m/);
|
||||||
|
|
Loading…
Add table
Reference in a new issue