From 0fb7bf849e5c9d17c7eb48a73f33cc2a0dbabc50 Mon Sep 17 00:00:00 2001 From: Allegiance Zone pusher Date: Sat, 11 Feb 2023 18:54:24 -0600 Subject: [PATCH] Add HTML::Strip and always support HTML messages Does not mess with send-code --- scripts/patrix | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/patrix b/scripts/patrix index 84ef1af..9894d0e 100644 --- a/scripts/patrix +++ b/scripts/patrix @@ -15,8 +15,10 @@ use URI::Escape; use Term::ReadKey; use Hash::Merge::Simple qw(merge); use Scalar::Util qw(looks_like_number); +use HTML::Strip; our $opt; +our $hs = HTML::Strip->new(); GetOptions( "user=s" => \$opt->{user}, @@ -256,8 +258,12 @@ sub send_msg { } my $json = { msgtype => ($opt->{action} eq 'send-notice') ? 'm.notice' : 'm.text', - body => $opt->{message} + body => $hs->parse($opt->{message}), + formatted_body => $opt->{message}, + format => "org.matrix.custom.html", }; + $hs->eof(); + # If we send code, we have to format it correctly if ($opt->{action} eq 'send-code'){ $json->{formatted_body} = '
' . $opt->{message} . '
';