mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 06:39:11 +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.
|
||||
# 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
|
||||
- feature: 93_DbRep: values next_day_begin, next_day_end for time attributes
|
||||
- feature: 23_LUXTRONIK2: new set parameter opModeVentilation
|
||||
|
@ -91,6 +91,7 @@ BEGIN {
|
||||
CommandAttr
|
||||
CommandDefine
|
||||
CommandGet
|
||||
CommandTrigger
|
||||
data
|
||||
defs
|
||||
devspec2array
|
||||
@ -134,6 +135,8 @@ BEGIN {
|
||||
|
||||
# Versions History intern
|
||||
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.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 ",
|
||||
@ -859,6 +862,11 @@ sub getApiSites {
|
||||
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
|
||||
for my $idx (sort{$a<=>$b} keys %{$data{SSChatBot}{$name}{sendqueue}{entries}}) {
|
||||
if (!$data{SSChatBot}{$name}{sendqueue}{entries}{$idx}{forbidSend} || $hash->{HELPER}{RESENDFORCE}) {
|
||||
@ -1178,7 +1186,7 @@ sub _parseUsers {
|
||||
my $name = $hash->{NAME};
|
||||
|
||||
my ($un,$ui,$st,$nn,$em,$uids);
|
||||
my %users = ();
|
||||
my %users;
|
||||
my $i = 0;
|
||||
|
||||
my $out = "<html>";
|
||||
@ -1207,9 +1215,17 @@ sub _parseUsers {
|
||||
$i++;
|
||||
}
|
||||
|
||||
$hash->{HELPER}{USERS} = \%users if(%users);
|
||||
if(%users) {
|
||||
$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 $list = $modules{$hash->{TYPE}}{AttrList};
|
||||
my @deva = split(" ", $list);
|
||||
@ -1295,6 +1311,9 @@ sub _parseSendItem {
|
||||
|
||||
my $postid = "";
|
||||
my $idx = $hash->{OPIDX};
|
||||
|
||||
return if(!$idx);
|
||||
|
||||
my $uid = $data{SSChatBot}{$name}{sendqueue}{entries}{$idx}{userid};
|
||||
|
||||
if($data->{data}{succ}{user_id_post_map}{$uid}) {
|
||||
|
@ -25,6 +25,9 @@
|
||||
#
|
||||
#########################################################################################################################
|
||||
|
||||
# Version History
|
||||
# 1.20.6 delete $hash->{OPMODE} in checkSendRetry
|
||||
|
||||
package FHEM::SynoModules::SMUtils;
|
||||
|
||||
use strict;
|
||||
@ -42,7 +45,7 @@ use FHEM::SynoModules::ErrCodes qw(:all); # Erro
|
||||
use GPUtils qw( GP_Import GP_Export );
|
||||
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');
|
||||
our @EXPORT_OK = qw(
|
||||
@ -1601,8 +1604,11 @@ sub checkSendRetry {
|
||||
my $startfn = shift // carp $carpnotfn && return;
|
||||
my $hash = $defs{$name};
|
||||
my $idx = $hash->{OPIDX};
|
||||
my $opmode = $hash->{OPMODE};
|
||||
my $type = $hash->{TYPE};
|
||||
|
||||
$hash->{OPMODE} = q{};
|
||||
|
||||
my $forbidSend = q{};
|
||||
my $startfnref = \&{$startfn};
|
||||
|
||||
@ -1620,7 +1626,7 @@ sub checkSendRetry {
|
||||
if(!$retry) { # Befehl erfolgreich, Senden nur neu starten wenn weitere Einträge in SendQueue
|
||||
delete $hash->{OPIDX};
|
||||
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);
|
||||
|
||||
if(keys %{$data{$type}{$name}{sendqueue}{entries}}) {
|
||||
@ -1642,10 +1648,9 @@ sub checkSendRetry {
|
||||
$forbidSend = expErrors($hash,$errorcode); # Fehlertext zum Errorcode ermitteln
|
||||
$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->{OPMODE};
|
||||
|
||||
updQueueLength ($hash); # updaten Länge der Sendequeue
|
||||
|
||||
@ -1662,7 +1667,7 @@ sub checkSendRetry {
|
||||
: 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
|
||||
updQueueLength ($hash, $rst); # updaten Länge der Sendequeue mit resend Timer
|
||||
|
Loading…
Reference in New Issue
Block a user