From 7a12ed3de33a794b5ca041c7117ed452122bbfc6 Mon Sep 17 00:00:00 2001 From: DS_Starter Date: Sat, 30 Nov 2019 09:29:33 +0000 Subject: [PATCH] 50_SSChatBot: contrib 1.0.0 git-svn-id: https://svn.fhem.de/fhem/trunk@20625 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/contrib/DS_Starter/50_SSChatBot.pm | 30 ++++++++++++++++--------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/fhem/contrib/DS_Starter/50_SSChatBot.pm b/fhem/contrib/DS_Starter/50_SSChatBot.pm index 5a51ad554..8a7baa5ca 100644 --- a/fhem/contrib/DS_Starter/50_SSChatBot.pm +++ b/fhem/contrib/DS_Starter/50_SSChatBot.pm @@ -323,14 +323,21 @@ sub SSChatBot_Set($@) { # text="a fun image" fileUrl="http://imgur.com/xxxxx" users="user1,user2" my $cmd = join(" ", @a); my ($text,$users,$fileUrl); - my($a, $h) = parseParams($cmd); + my ($a,$h) = parseParams($cmd); if($h) { $text = $h->{text} if(defined $h->{text}); $users = $h->{users} if(defined $h->{users}); $fileUrl = $h->{fileUrl} if(defined $h->{fileUrl}); } + + if($a) { + my @t = @{$a}; + shift @t; shift @t; + $text = join(" ", @t); + Log3($name, 1, "$name - sendItem: ".$text); + } - return "Your sendstring is incorrect. It must contain at least the \"text\" tag like 'text=\"...\" '." if(!$text); + return "Your sendstring is incorrect. It must contain at least text with the \"text\" tag like 'text=\"...\"\nor only some text like \"this is a test\" '." if(!$text); $users = AttrVal($name,"defaultPeer", "") if(!$users); return "You haven't defined any receptor for send the message to. ". @@ -1457,14 +1464,17 @@ sub SSChatBot_CGI() { readingsBeginUpdate($hash); - readingsBulkUpdate ($hash, "recChannelid", $channelid); - readingsBulkUpdate ($hash, "recChannelname", $channelname); - readingsBulkUpdate ($hash, "recUserid", $userid); - readingsBulkUpdate ($hash, "recUsername", $username); - readingsBulkUpdate ($hash, "recPostid", $postid); - readingsBulkUpdate ($hash, "recTimestamp", $timestamp); - readingsBulkUpdate ($hash, "recText", $text); - readingsBulkUpdate ($hash, "recTriggerword", $triggerword); + readingsBulkUpdateIfChanged ($hash, "recChannelid", $channelid); + readingsBulkUpdateIfChanged ($hash, "recChannelname", $channelname); + readingsBulkUpdateIfChanged ($hash, "recUserid", $userid); + readingsBulkUpdateIfChanged ($hash, "recUsername", $username); + readingsBulkUpdateIfChanged ($hash, "recPostid", $postid); + readingsBulkUpdateIfChanged ($hash, "recTimestamp", $timestamp); + readingsBulkUpdateIfChanged ($hash, "recText", $text); + readingsBulkUpdateIfChanged ($hash, "recTriggerword", $triggerword); + readingsBulkUpdateIfChanged ($hash,"Errorcode","none"); + readingsBulkUpdateIfChanged ($hash,"Error","none"); + readingsBulkUpdate ($hash, "state", "active"); readingsEndUpdate ($hash,1); return ("text/plain; charset=utf-8", "success");