Hi haukex,

in my private environment I follow some logfiles by File::Tail and report lines of interest to some TELEGRAM Channel via WWW::Telegram::BotAPI. The TELEGRAM API knows some forms of limited formatting of the string to send. One of the formatting options is called "HTML", although there are only 3 or 4 fomatting tags similar to the HTML tags.

One e.g. is:

<strong>xxx</strong>

The example I gave is very much the same as a real logfile line. But if you wish I can give a real example:

$av_tmp_LINE = "Jun 3 23:20:05 f42252s5 postfix/pickup[204714]: E1E63 +A045C: uid=33 from=<www-data>" $av_tmp_STRING = "Logfile: " . "<strong>" . $av_obj_TMP->{input} . "</ +strong>" . " " . $av_tmp_LINE;

Now the string $av_tmp_STRING should be sent to the TELEGRAM Channel using "HTML" formatting. But unfotunately inside the string there is the "<www-data>" which looks like a formatting string, but is unsupported.

This causes the module to abort, although eval is used.

Messge:

"Request failed with error 'ERROR: code 400: Bad Request: can't parse +entities: Unsupported start tag "www" at byte offset 53 at /usr/share +/perl5/WWW/Telegram/BotAPI.pm line 224. WWW::Telegram::BotAPI::api_re +quest(undef, undef, HASH(0x55e57ea8da98)) called at ./av_perlre.pl li +ne 268 eval {...} called at ./av_perlre.pl line 266 ', but I'm still +alive! at ./av_perlre.pl line 266."

Since I am not a very experience programmer, I probably have done something wrong. I have already reported the issue to the module creator.

My Code:

$av_std_RETVAL = eval { $av_obj_TGRAM->sendMessage ( { chat_id => $av_loc_tgram_CHATID, text => $av_tmp_STRING, disable_notification => 'false', parse_mode => 'HTML', } ) } or warn "Request failed with error '$@', but I'm still alive!";

This is according to the docu. The docu says, by using eval the way above, the program will not abort - but it does.

Regards Kallewirsch

In reply to Re^4: perlre inverse check for several patterns by averlon
in thread perlre inverse check for several patterns by averlon

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.