mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-07 19:04:20 +00:00
50_SSChatBot: contrib 1.0.1
git-svn-id: https://svn.fhem.de/fhem/trunk@20713 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
c23cdb276c
commit
eeb4e71359
@ -54,14 +54,15 @@ our %SSChatBot_vNotesIntern = (
|
|||||||
|
|
||||||
# Versions History extern
|
# Versions History extern
|
||||||
our %SSChatBot_vNotesExtern = (
|
our %SSChatBot_vNotesExtern = (
|
||||||
"1.0.0" => "12.12.2015 initial "
|
"1.0.1" => "11.12.2019 check OPIDX in parse sendItem, change error code list, complete forbidSend with error text ",
|
||||||
|
"1.0.0" => "08.12.2019 initial "
|
||||||
);
|
);
|
||||||
|
|
||||||
my %SSChatBot_errlist = (
|
my %SSChatBot_errlist = (
|
||||||
100 => "Unknown error",
|
100 => "Unknown error",
|
||||||
101 => "Payload is empty",
|
101 => "Payload is empty",
|
||||||
102 => "API does not exist - may be the Synology Chat Server package is stopped",
|
102 => "API does not exist - may be the Synology Chat Server package is stopped",
|
||||||
117 => "file or file location not valid",
|
117 => "illegal file name or path",
|
||||||
120 => "payload has wrong format",
|
120 => "payload has wrong format",
|
||||||
404 => "bot is not legal - may be the bot is not active or the botToken is wrong",
|
404 => "bot is not legal - may be the bot is not active or the botToken is wrong",
|
||||||
407 => "record not valid",
|
407 => "record not valid",
|
||||||
@ -678,7 +679,7 @@ sub SSChatBot_checkretry ($$) {
|
|||||||
my ($name,$retry) = @_;
|
my ($name,$retry) = @_;
|
||||||
my $hash = $defs{$name};
|
my $hash = $defs{$name};
|
||||||
my $idx = $hash->{OPIDX};
|
my $idx = $hash->{OPIDX};
|
||||||
my $forbidSend = 0;
|
my $forbidSend = "";
|
||||||
|
|
||||||
if(!keys %{$data{SSChatBot}{$name}{sendqueue}{entries}}) {
|
if(!keys %{$data{SSChatBot}{$name}{sendqueue}{entries}}) {
|
||||||
Log3($name, 4, "$name - SendQueue is empty. Nothing to do ...");
|
Log3($name, 4, "$name - SendQueue is empty. Nothing to do ...");
|
||||||
@ -686,20 +687,20 @@ sub SSChatBot_checkretry ($$) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$retry) { # Befehl erfolgreich, Senden nur neu starten wenn weitere Einträge in SendQueue
|
if(!$retry) { # Befehl erfolgreich, Senden nur neu starten wenn weitere Einträge in SendQueue
|
||||||
delete $hash->{OPIDX};
|
delete $hash->{OPIDX};
|
||||||
delete $data{SSChatBot}{$name}{sendqueue}{entries}{$idx};
|
delete $data{SSChatBot}{$name}{sendqueue}{entries}{$idx};
|
||||||
Log3($name, 4, "$name - Opmode \"$hash->{OPMODE}\" finished successfully, Sendqueue index \"$idx\" deleted.");
|
Log3($name, 4, "$name - Opmode \"$hash->{OPMODE}\" finished successfully, Sendqueue index \"$idx\" deleted.");
|
||||||
SSChatBot_updQLength ($hash);
|
SSChatBot_updQLength ($hash);
|
||||||
return SSChatBot_getapisites($name); # nächsten Eintrag abarbeiten (wenn SendQueue nicht leer)
|
return SSChatBot_getapisites($name); # nächsten Eintrag abarbeiten (wenn SendQueue nicht leer)
|
||||||
|
|
||||||
} else { # Befehl nicht erfolgreich, (verzögertes) Senden einplanen
|
} else { # Befehl nicht erfolgreich, (verzögertes) Senden einplanen
|
||||||
$data{SSChatBot}{$name}{sendqueue}{entries}{$idx}{retryCount}++;
|
$data{SSChatBot}{$name}{sendqueue}{entries}{$idx}{retryCount}++;
|
||||||
my $rc = $data{SSChatBot}{$name}{sendqueue}{entries}{$idx}{retryCount};
|
my $rc = $data{SSChatBot}{$name}{sendqueue}{entries}{$idx}{retryCount};
|
||||||
|
|
||||||
my $errorcode = ReadingsVal($name, "Errorcode", 0);
|
my $errorcode = ReadingsVal($name, "Errorcode", 0);
|
||||||
if($errorcode =~ /100|101|117|120|407|409|800|900/) { # bei diesen Errorcodes den Queueeintrag nicht wiederholen, da dauerhafter Fehler !
|
if($errorcode =~ /100|101|117|120|407|409|800|900/) { # bei diesen Errorcodes den Queueeintrag nicht wiederholen, da dauerhafter Fehler !
|
||||||
$forbidSend = 1;
|
$forbidSend = SSChatBot_experror($hash,$errorcode); # Fehlertext zum Errorcode ermitteln
|
||||||
$data{SSChatBot}{$name}{sendqueue}{entries}{$idx}{forbidSend} = $forbidSend;
|
$data{SSChatBot}{$name}{sendqueue}{entries}{$idx}{forbidSend} = $forbidSend;
|
||||||
|
|
||||||
Log3($name, 2, "$name - ERROR - \"$hash->{OPMODE}\" SendQueue index \"$idx\" not executed. It seems to be a permanent error. Exclude it from new send attempt !");
|
Log3($name, 2, "$name - ERROR - \"$hash->{OPMODE}\" SendQueue index \"$idx\" not executed. It seems to be a permanent error. Exclude it from new send attempt !");
|
||||||
@ -707,9 +708,9 @@ sub SSChatBot_checkretry ($$) {
|
|||||||
delete $hash->{OPIDX};
|
delete $hash->{OPIDX};
|
||||||
delete $hash->{OPMODE};
|
delete $hash->{OPMODE};
|
||||||
|
|
||||||
SSChatBot_updQLength ($hash); # updaten Länge der Sendequeue
|
SSChatBot_updQLength ($hash); # updaten Länge der Sendequeue
|
||||||
|
|
||||||
return SSChatBot_getapisites($name); # nächsten Eintrag abarbeiten (wenn SendQueue nicht leer);
|
return SSChatBot_getapisites($name); # nächsten Eintrag abarbeiten (wenn SendQueue nicht leer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$forbidSend) {
|
if(!$forbidSend) {
|
||||||
@ -1135,7 +1136,7 @@ sub SSChatBot_chatop_parse ($) {
|
|||||||
asyncOutput($hash->{HELPER}{CL}{1},"$out");
|
asyncOutput($hash->{HELPER}{CL}{1},"$out");
|
||||||
delete($hash->{HELPER}{CL});
|
delete($hash->{HELPER}{CL});
|
||||||
|
|
||||||
} elsif ($opmode eq "sendItem") {
|
} elsif ($opmode eq "sendItem" && $hash->{OPIDX}) {
|
||||||
my $postid = "";
|
my $postid = "";
|
||||||
my $idx = $hash->{OPIDX};
|
my $idx = $hash->{OPIDX};
|
||||||
my $uid = $data{SSChatBot}{$name}{sendqueue}{entries}{$idx}{userid};
|
my $uid = $data{SSChatBot}{$name}{sendqueue}{entries}{$idx}{userid};
|
||||||
@ -1161,7 +1162,7 @@ sub SSChatBot_chatop_parse ($) {
|
|||||||
# die API-Operation war fehlerhaft
|
# die API-Operation war fehlerhaft
|
||||||
# Errorcode aus JSON ermitteln
|
# Errorcode aus JSON ermitteln
|
||||||
$errorcode = $data->{'error'}->{'code'};
|
$errorcode = $data->{'error'}->{'code'};
|
||||||
$cherror = $data->{'error'}->{'errors'}; # vom Chat gelieferter Fehler
|
$cherror = $data->{'error'}->{'errors'}; # vom Chat gelieferter Fehler
|
||||||
$error = SSChatBot_experror($hash,$errorcode); # Fehlertext zum Errorcode ermitteln
|
$error = SSChatBot_experror($hash,$errorcode); # Fehlertext zum Errorcode ermitteln
|
||||||
if ($error =~ /not found/) {
|
if ($error =~ /not found/) {
|
||||||
$error .= " New error: ".($cherror?$cherror:"");
|
$error .= " New error: ".($cherror?$cherror:"");
|
||||||
@ -1807,8 +1808,8 @@ sub SSChatBot_CGI() {
|
|||||||
1;
|
1;
|
||||||
|
|
||||||
=pod
|
=pod
|
||||||
=item summary module to use a Synology Chat Bot
|
=item summary module to integrate Synology Chat into FHEM
|
||||||
=item summary_DE Modul zur Installation eines Synology Chat Bot
|
=item summary_DE Modul zur Integration von Synology Chat in FHEM
|
||||||
=begin html
|
=begin html
|
||||||
|
|
||||||
<a name="SSChatBot"></a>
|
<a name="SSChatBot"></a>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user