Add HTML::Strip and always support HTML messages

Does not mess with send-code
This commit is contained in:
Allegiance Zone pusher 2023-02-11 18:54:24 -06:00 committed by GitHub
parent 2ea3589c4c
commit 0fb7bf849e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -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} = '<pre><code>' . $opt->{message} . '</code></pre>';