3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-22 20:09:43 +01:00

WebPaste: Encode output as UTF-8

This commit is contained in:
Pragmatic Software 2019-06-30 20:47:49 -07:00
parent 8f98d3d55c
commit c399116c4e

View File

@ -16,6 +16,7 @@ use Time::HiRes qw/gettimeofday/;
use Time::Duration;
use LWP::UserAgent;
use Carp ();
use Encode;
sub new {
if (ref($_[1]) eq 'HASH') {
@ -55,9 +56,10 @@ sub get_paste_site {
sub paste {
my ($self, $text) = @_;
$text = encode('UTF-8', $text);
$text =~ s/(.{120})\s/$1\n/g;
my $result;
my $result;
for (my $tries = 5; $tries > 0; $tries--) {
my $paste_site = $self->get_paste_site;
$result = $paste_site->($text);