From d9c3cfda3ba9ed8a6599b2cb8e8eb131ffd59142 Mon Sep 17 00:00:00 2001 From: DS_Starter Date: Fri, 19 May 2023 13:16:31 +0000 Subject: [PATCH] 50_SSChatBot: contrib 1.15.0 git-svn-id: https://svn.fhem.de/fhem/trunk@27592 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/contrib/DS_Starter/50_SSChatBot.pm | 29 ++++++++++++++++--------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/fhem/contrib/DS_Starter/50_SSChatBot.pm b/fhem/contrib/DS_Starter/50_SSChatBot.pm index 4ba761c01..33aca4c4c 100644 --- a/fhem/contrib/DS_Starter/50_SSChatBot.pm +++ b/fhem/contrib/DS_Starter/50_SSChatBot.pm @@ -136,6 +136,7 @@ BEGIN { # Versions History intern my %vNotesIntern = ( + "1.15.0" => "19.05.2023 Test ", "1.14.0" => "08.04.2023 prepared for new Setter deletePostId, loglevel for HttpUtils ", "1.13.0" => "14.01.2023 new attr spareHost, sparePort ", "1.12.1" => "28.11.2020 fix cannot send after received anything, fix greedy regex in _botCGIcheckData ", @@ -1130,20 +1131,20 @@ sub chatOp { Log3($name, 5, "$name - HTTP-Call will be done with httptimeout: $httptimeout s"); if ($opmode =~ /^chatUserlist$|^chatChannellist$/x) { - $url = "$inprot://$inaddr:$inport/webapi/$extapipath?api=$extapi&version=$exapiver&method=$method&token=\"$token\""; + $url = qq($inprot://$inaddr:$inport/webapi/$extapipath?api=$extapi&version=$exapiver&method=$method&token="$token"); } elsif ($opmode eq 'sendItem') { # Form: payload={"text": "a fun image", "file_url": "http://imgur.com/xxxxx" "user_ids": [5]} # payload={"text": "First line of message to post in the channel" "user_ids": [5]} # payload={"text": "Check this!! for details!" "user_ids": [5]} - $url = "$inprot://$inaddr:$inport/webapi/$extapipath?api=$extapi&version=$exapiver&method=$method&token=\"$token\""; - $url .= "&payload={"; - $url .= "\"text\": \"$text\"," if($text); - $url .= "\"file_url\": \"$fileUrl\"," if($fileUrl); - $url .= "\"attachments\": $attachment," if($attachment); - $url .= "\"user_ids\": [$userid]" if($userid); - $url .= "}"; + $url = qq($inprot://$inaddr:$inport/webapi/$extapipath?api=$extapi&version=$exapiver&method=$method&token="$token"); + $url .= qq(&payload={); + $url .= qq("text": "$text",) if($text); + $url .= qq("file_url": "$fileUrl",) if($fileUrl); + $url .= qq("attachments": $attachment,) if($attachment); + $url .= qq("user_ids": [$userid]) if($userid); + $url .= qq(}); } elsif ($opmode eq 'delPostId') { $method = $data{SSChatBot}{$name}{sendqueue}{entries}{$idx}{method}; @@ -1156,7 +1157,7 @@ sub chatOp { else { return; } - + my $part = $url; if(AttrVal($name, "showTokenInLog", "0") == 1) { @@ -1167,6 +1168,8 @@ sub chatOp { Log3 ($name, 4, "$name - Call-Out >$humethod<: $part"); } + $url = formString ($url, 'url'); + $param = { url => $url, timeout => $httptimeout, @@ -1482,7 +1485,13 @@ sub formString { my $func = shift; my ($replacements,$pat); - if($func ne "attachement") { + if ($func eq 'url') { + $replacements = { + '"' => "%22", + " " => "%20", + } + } + elsif ($func ne 'attachement') { $replacements = { '"' => "´", # doppelte Hochkomma sind im Text nicht erlaubt " H" => "%20H", # Bug in HttpUtils(?) wenn vor großem H ein Zeichen + Leerzeichen vorangeht