mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 12:49:34 +00:00
50_SSChatBot: do once event CHAT_INITIALIZED when users are loaded
git-svn-id: https://svn.fhem.de/fhem/trunk@23220 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
6f60d16df0
commit
521ad6b213
@ -1,5 +1,7 @@
|
|||||||
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
||||||
# Do not insert empty lines here, update check depends on it.
|
# Do not insert empty lines here, update check depends on it.
|
||||||
|
- change: 50_SSChatBot: do once event CHAT_INITIALIZED when users are loaded,
|
||||||
|
(also update SMUtils.pm)
|
||||||
- bugfix: 93_DbRep: fix undefined ARRAY reference in reduceLog, Forum:#116057
|
- bugfix: 93_DbRep: fix undefined ARRAY reference in reduceLog, Forum:#116057
|
||||||
- feature: 93_DbRep: values next_day_begin, next_day_end for time attributes
|
- feature: 93_DbRep: values next_day_begin, next_day_end for time attributes
|
||||||
- feature: 23_LUXTRONIK2: new set parameter opModeVentilation
|
- feature: 23_LUXTRONIK2: new set parameter opModeVentilation
|
||||||
|
@ -91,6 +91,7 @@ BEGIN {
|
|||||||
CommandAttr
|
CommandAttr
|
||||||
CommandDefine
|
CommandDefine
|
||||||
CommandGet
|
CommandGet
|
||||||
|
CommandTrigger
|
||||||
data
|
data
|
||||||
defs
|
defs
|
||||||
devspec2array
|
devspec2array
|
||||||
@ -134,6 +135,8 @@ BEGIN {
|
|||||||
|
|
||||||
# Versions History intern
|
# Versions History intern
|
||||||
my %vNotesIntern = (
|
my %vNotesIntern = (
|
||||||
|
"1.12.0" => "23.11.2020 generate event CHAT_INITIALIZED when users are once loaded, Forum: https://forum.fhem.de/index.php/topic,105714.msg1103700.html#msg1103700 ".
|
||||||
|
"postpone new operation is one ist still running ",
|
||||||
"1.11.7" => "01.11.2020 quotation marks can be used in text tag of received messages (__botCGIcheckData) ",
|
"1.11.7" => "01.11.2020 quotation marks can be used in text tag of received messages (__botCGIcheckData) ",
|
||||||
"1.11.6" => "08.10.2020 add urlEncode of character codes like \x{c3}\x{85} to formString ",
|
"1.11.6" => "08.10.2020 add urlEncode of character codes like \x{c3}\x{85} to formString ",
|
||||||
"1.11.5" => "06.10.2020 use addSendqueue from SMUtils, delete local addSendqueue ",
|
"1.11.5" => "06.10.2020 use addSendqueue from SMUtils, delete local addSendqueue ",
|
||||||
@ -859,6 +862,11 @@ sub getApiSites {
|
|||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($hash->{OPMODE}) { # Überholer vermeiden wenn eine Operation läuft (V. 1.12.0" => "23.11.2020)
|
||||||
|
Log3($name, 4, qq{$name - Operation "$hash->{OPMODE} (idx: $hash->{OPIDX})" is still running. Next operation start postponed});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
# den nächsten Eintrag aus "SendQueue" selektieren und ausführen wenn nicht forbidSend gesetzt ist
|
# den nächsten Eintrag aus "SendQueue" selektieren und ausführen wenn nicht forbidSend gesetzt ist
|
||||||
for my $idx (sort{$a<=>$b} keys %{$data{SSChatBot}{$name}{sendqueue}{entries}}) {
|
for my $idx (sort{$a<=>$b} keys %{$data{SSChatBot}{$name}{sendqueue}{entries}}) {
|
||||||
if (!$data{SSChatBot}{$name}{sendqueue}{entries}{$idx}{forbidSend} || $hash->{HELPER}{RESENDFORCE}) {
|
if (!$data{SSChatBot}{$name}{sendqueue}{entries}{$idx}{forbidSend} || $hash->{HELPER}{RESENDFORCE}) {
|
||||||
@ -983,7 +991,7 @@ sub getApiSites_parse {
|
|||||||
Log3 ($name, 4, "$name - API completed:\n".Dumper $hash->{HELPER}{API});
|
Log3 ($name, 4, "$name - API completed:\n".Dumper $hash->{HELPER}{API});
|
||||||
|
|
||||||
if ($opmode eq "apiInfo") { # API Infos in Popup anzeigen
|
if ($opmode eq "apiInfo") { # API Infos in Popup anzeigen
|
||||||
showAPIinfo ($hash, $hash->{HELPER}{API}); # übergibt Referenz zum instanziierten API-Hash)
|
showAPIinfo ($hash, $hash->{HELPER}{API}); # übergibt Referenz zum instanziierten API-Hash)
|
||||||
checkSendRetry ($name, 0, $queueStartFn);
|
checkSendRetry ($name, 0, $queueStartFn);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1178,7 +1186,7 @@ sub _parseUsers {
|
|||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
|
|
||||||
my ($un,$ui,$st,$nn,$em,$uids);
|
my ($un,$ui,$st,$nn,$em,$uids);
|
||||||
my %users = ();
|
my %users;
|
||||||
my $i = 0;
|
my $i = 0;
|
||||||
|
|
||||||
my $out = "<html>";
|
my $out = "<html>";
|
||||||
@ -1207,8 +1215,16 @@ sub _parseUsers {
|
|||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$hash->{HELPER}{USERS} = \%users if(%users);
|
if(%users) {
|
||||||
$hash->{HELPER}{USERFETCHED} = 1;
|
$hash->{HELPER}{USERS} = \%users;
|
||||||
|
my $olduf = $hash->{HELPER}{USERFETCHED};
|
||||||
|
$hash->{HELPER}{USERFETCHED} = 1;
|
||||||
|
|
||||||
|
if(!$olduf) {
|
||||||
|
my $event = "CHAT_INITIALIZED";
|
||||||
|
CommandTrigger(undef, "$name $event");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
my @newa;
|
my @newa;
|
||||||
my $list = $modules{$hash->{TYPE}}{AttrList};
|
my $list = $modules{$hash->{TYPE}}{AttrList};
|
||||||
@ -1295,6 +1311,9 @@ sub _parseSendItem {
|
|||||||
|
|
||||||
my $postid = "";
|
my $postid = "";
|
||||||
my $idx = $hash->{OPIDX};
|
my $idx = $hash->{OPIDX};
|
||||||
|
|
||||||
|
return if(!$idx);
|
||||||
|
|
||||||
my $uid = $data{SSChatBot}{$name}{sendqueue}{entries}{$idx}{userid};
|
my $uid = $data{SSChatBot}{$name}{sendqueue}{entries}{$idx}{userid};
|
||||||
|
|
||||||
if($data->{data}{succ}{user_id_post_map}{$uid}) {
|
if($data->{data}{succ}{user_id_post_map}{$uid}) {
|
||||||
@ -1370,7 +1389,7 @@ sub formString {
|
|||||||
"+" => "%2B",
|
"+" => "%2B",
|
||||||
};
|
};
|
||||||
|
|
||||||
%$replacements = (%$replacements, %$enctourl);
|
%$replacements = (%$replacements, %$enctourl);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$replacements = {
|
$replacements = {
|
||||||
|
@ -25,6 +25,9 @@
|
|||||||
#
|
#
|
||||||
#########################################################################################################################
|
#########################################################################################################################
|
||||||
|
|
||||||
|
# Version History
|
||||||
|
# 1.20.6 delete $hash->{OPMODE} in checkSendRetry
|
||||||
|
|
||||||
package FHEM::SynoModules::SMUtils;
|
package FHEM::SynoModules::SMUtils;
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
@ -42,7 +45,7 @@ use FHEM::SynoModules::ErrCodes qw(:all); # Erro
|
|||||||
use GPUtils qw( GP_Import GP_Export );
|
use GPUtils qw( GP_Import GP_Export );
|
||||||
use Carp qw(croak carp);
|
use Carp qw(croak carp);
|
||||||
|
|
||||||
use version; our $VERSION = version->declare('1.20.5');
|
use version; our $VERSION = version->declare('1.20.6');
|
||||||
|
|
||||||
use Exporter ('import');
|
use Exporter ('import');
|
||||||
our @EXPORT_OK = qw(
|
our @EXPORT_OK = qw(
|
||||||
@ -1601,8 +1604,11 @@ sub checkSendRetry {
|
|||||||
my $startfn = shift // carp $carpnotfn && return;
|
my $startfn = shift // carp $carpnotfn && return;
|
||||||
my $hash = $defs{$name};
|
my $hash = $defs{$name};
|
||||||
my $idx = $hash->{OPIDX};
|
my $idx = $hash->{OPIDX};
|
||||||
|
my $opmode = $hash->{OPMODE};
|
||||||
my $type = $hash->{TYPE};
|
my $type = $hash->{TYPE};
|
||||||
|
|
||||||
|
$hash->{OPMODE} = q{};
|
||||||
|
|
||||||
my $forbidSend = q{};
|
my $forbidSend = q{};
|
||||||
my $startfnref = \&{$startfn};
|
my $startfnref = \&{$startfn};
|
||||||
|
|
||||||
@ -1620,7 +1626,7 @@ sub checkSendRetry {
|
|||||||
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{$type}{$name}{sendqueue}{entries}{$idx};
|
delete $data{$type}{$name}{sendqueue}{entries}{$idx};
|
||||||
Log3($name, 4, qq{$name - Opmode "$hash->{OPMODE}" finished successfully, Sendqueue index "$idx" deleted.});
|
Log3($name, 4, qq{$name - Opmode "$opmode" finished successfully, Sendqueue index "$idx" deleted.});
|
||||||
updQueueLength ($hash);
|
updQueueLength ($hash);
|
||||||
|
|
||||||
if(keys %{$data{$type}{$name}{sendqueue}{entries}}) {
|
if(keys %{$data{$type}{$name}{sendqueue}{entries}}) {
|
||||||
@ -1642,10 +1648,9 @@ sub checkSendRetry {
|
|||||||
$forbidSend = expErrors($hash,$errorcode); # Fehlertext zum Errorcode ermitteln
|
$forbidSend = expErrors($hash,$errorcode); # Fehlertext zum Errorcode ermitteln
|
||||||
$data{$type}{$name}{sendqueue}{entries}{$idx}{forbidSend} = $forbidSend;
|
$data{$type}{$name}{sendqueue}{entries}{$idx}{forbidSend} = $forbidSend;
|
||||||
|
|
||||||
Log3($name, 2, qq{$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, qq{$name - ERROR - "$opmode" SendQueue index "$idx" not executed. It seems to be a permanent error. Exclude it from new send attempt !});
|
||||||
|
|
||||||
delete $hash->{OPIDX};
|
delete $hash->{OPIDX};
|
||||||
delete $hash->{OPMODE};
|
|
||||||
|
|
||||||
updQueueLength ($hash); # updaten Länge der Sendequeue
|
updQueueLength ($hash); # updaten Länge der Sendequeue
|
||||||
|
|
||||||
@ -1662,7 +1667,7 @@ sub checkSendRetry {
|
|||||||
: 86400
|
: 86400
|
||||||
;
|
;
|
||||||
|
|
||||||
Log3($name, 2, qq{$name - ERROR - "$hash->{OPMODE}" SendQueue index "$idx" not executed. Restart SendQueue in $rs s (retryCount $rc).});
|
Log3($name, 2, qq{$name - ERROR - "$opmode" SendQueue index "$idx" not executed. Restart SendQueue in $rs s (retryCount $rc).});
|
||||||
|
|
||||||
my $rst = gettimeofday()+$rs; # resend Timer
|
my $rst = gettimeofday()+$rs; # resend Timer
|
||||||
updQueueLength ($hash, $rst); # updaten Länge der Sendequeue mit resend Timer
|
updQueueLength ($hash, $rst); # updaten Länge der Sendequeue mit resend Timer
|
||||||
|
Loading…
Reference in New Issue
Block a user