2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-02-25 16:05:19 +00:00

50_TelegramBot: new reading msgDate and corrections

git-svn-id: https://svn.fhem.de/fhem/trunk@27218 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
viegener 2023-02-13 22:45:48 +00:00
parent bb4aa0b806
commit a0c266923f
2 changed files with 31 additions and 19 deletions

View File

@ -1,5 +1,6 @@
# 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_TelegramBot: new reading msgDate and corrections
- feature: 72_FRITZBOX: Attr. enableWanInfo -> enableWLANneighbors - feature: 72_FRITZBOX: Attr. enableWanInfo -> enableWLANneighbors
Attr. wlanNeighborsPrefix Attr. wlanNeighborsPrefix
Fehlerkorrekturen <prefix> Fehlerkorrekturen <prefix>

View File

@ -194,7 +194,11 @@
# #msg1168649: Corrected logging verbose to make 0_None work # #msg1168649: Corrected logging verbose to make 0_None work
# caption parseMode / formatting also available for photo and video sends # caption parseMode / formatting also available for photo and video sends
# # avoid warning for incomplete msgDelete commands
# replaceSetMagic on favorites not done before execution
# add reading msgDate
# update documentation
# #
############################################################################## ##############################################################################
# TASKS # TASKS
@ -202,7 +206,6 @@
# Customize Favoriten beendet --> msg1133794 # Customize Favoriten beendet --> msg1133794
# Option to delete message at the end insteda of sending "-" # Option to delete message at the end insteda of sending "-"
# #
#
# change doc to have "a name" on attributes to allow inline help # change doc to have "a name" on attributes to allow inline help
# Restructure help in logical blocks # Restructure help in logical blocks
# #
@ -766,6 +769,7 @@ sub TelegramBot_Set($@)
return "TelegramBot_Set: Command $cmd, msgId must be given as first parameter before peer" if ( $msgid =~ /^@/ ); return "TelegramBot_Set: Command $cmd, msgId must be given as first parameter before peer" if ( $msgid =~ /^@/ );
$numberOfArgs--; $numberOfArgs--;
if ( int(@args) > 0 ) {
while ( $args[0] =~ /^@(..+)$/ ) { while ( $args[0] =~ /^@(..+)$/ ) {
my $ppart = $1; my $ppart = $1;
return "TelegramBot_Set: Command $cmd, need exactly one peer" if ( defined( $peers ) ); return "TelegramBot_Set: Command $cmd, need exactly one peer" if ( defined( $peers ) );
@ -776,6 +780,7 @@ sub TelegramBot_Set($@)
shift @args; shift @args;
last if ( int(@args) == 0 ); last if ( int(@args) == 0 );
} }
}
if ( ! defined( $peers ) ) { if ( ! defined( $peers ) ) {
$peers = AttrVal($name,'defaultPeer',undef); $peers = AttrVal($name,'defaultPeer',undef);
@ -1469,14 +1474,14 @@ sub TelegramBot_ExecuteCommand($$$$;$$) {
if ( ! defined( $ret ) ) { if ( ! defined( $ret ) ) {
# run replace set magic on command - first # run replace set magic on command - first
my %dummy; my %dummy;
my ($err, @a) = ReplaceSetMagic(\%dummy, 0, ( $cmd ) ); # my ($err, @a) = ReplaceSetMagic(\%dummy, 0, ( $cmd ) );
if ( $err ) { # if ( $err ) {
Log3 $name, 1, "TelegramBot_ExecuteCommand $name: parse cmd failed on ReplaceSetmagic with :$err: on :$cmd:"; # Log3 $name, 1, "TelegramBot_ExecuteCommand $name: parse cmd failed on ReplaceSetmagic with :$err: on :$cmd:";
} else { # } else {
$cmd = join(" ", @a); # $cmd = join(" ", @a);
Log3 $name, 4, "TelegramBot_ExecuteCommand $name: parse cmd returned :$cmd:"; # Log3 $name, 4, "TelegramBot_ExecuteCommand $name: parse cmd returned :$cmd:";
} # }
$ret = AnalyzeCommandChain( $hash, $cmd ); $ret = AnalyzeCommandChain( $hash, $cmd );
@ -2506,6 +2511,8 @@ sub TelegramBot_ParseMsg($$$)
my $mid = $message->{message_id}; my $mid = $message->{message_id};
my $mdate = FmtDateTime( $message->{date} );
my $from = $message->{from}; my $from = $message->{from};
if ( ! defined( $from ) ) { if ( ! defined( $from ) ) {
Log3 $name, 3, "TelegramBot $name: No from user in message - blocked"; Log3 $name, 3, "TelegramBot $name: No from user in message - blocked";
@ -2667,6 +2674,7 @@ sub TelegramBot_ParseMsg($$$)
readingsBeginUpdate($hash); readingsBeginUpdate($hash);
readingsBulkUpdate($hash, "prevMsgId", $hash->{READINGS}{msgId}{VAL}); readingsBulkUpdate($hash, "prevMsgId", $hash->{READINGS}{msgId}{VAL});
readingsBulkUpdate($hash, "prevMsgDate", $hash->{READINGS}{msgDate}{VAL});
readingsBulkUpdate($hash, "prevMsgPeer", $hash->{READINGS}{msgPeer}{VAL}); readingsBulkUpdate($hash, "prevMsgPeer", $hash->{READINGS}{msgPeer}{VAL});
readingsBulkUpdate($hash, "prevMsgPeerId", $hash->{READINGS}{msgPeerId}{VAL}); readingsBulkUpdate($hash, "prevMsgPeerId", $hash->{READINGS}{msgPeerId}{VAL});
readingsBulkUpdate($hash, "prevMsgChat", $hash->{READINGS}{msgChat}{VAL}); readingsBulkUpdate($hash, "prevMsgChat", $hash->{READINGS}{msgChat}{VAL});
@ -2679,6 +2687,7 @@ sub TelegramBot_ParseMsg($$$)
readingsBeginUpdate($hash); readingsBeginUpdate($hash);
readingsBulkUpdate($hash, "msgId", $mid); readingsBulkUpdate($hash, "msgId", $mid);
readingsBulkUpdate($hash, "msgDate", $mdate);
readingsBulkUpdate($hash, "msgPeer", TelegramBot_GetFullnameForContact( $hash, $mpeernorm )); readingsBulkUpdate($hash, "msgPeer", TelegramBot_GetFullnameForContact( $hash, $mpeernorm ));
readingsBulkUpdate($hash, "msgPeerId", $mpeernorm); readingsBulkUpdate($hash, "msgPeerId", $mpeernorm);
readingsBulkUpdate($hash, "msgChat", TelegramBot_GetFullnameForContact( $hash, ((!$chatId)?$mpeernorm:$chatId) ) ); readingsBulkUpdate($hash, "msgChat", TelegramBot_GetFullnameForContact( $hash, ((!$chatId)?$mpeernorm:$chatId) ) );
@ -4137,6 +4146,7 @@ sub TelegramBot_BinaryFileWrite($$$) {
<br> <br>
<li>msgId &lt;text&gt;<br>The id of the last received message is stored in this reading. <li>msgId &lt;text&gt;<br>The id of the last received message is stored in this reading.
For secret chats a value of -1 will be given, since the msgIds of secret messages are not part of the consecutive numbering</li> For secret chats a value of -1 will be given, since the msgIds of secret messages are not part of the consecutive numbering</li>
<li>msgDate &lt;timestamp&gt;<br>The timestamp of the last message receied representing the time when it was sent to telegram</li>
<li>msgPeer &lt;text&gt;<br>The sender name of the last received message (either full name or if not available @username)</li> <li>msgPeer &lt;text&gt;<br>The sender name of the last received message (either full name or if not available @username)</li>
<li>msgPeerId &lt;text&gt;<br>The sender id of the last received message</li> <li>msgPeerId &lt;text&gt;<br>The sender id of the last received message</li>
<li>msgChat &lt;text&gt;<br>The name of the Chat in which the last message was received (might be the peer if no group involved)</li> <li>msgChat &lt;text&gt;<br>The name of the Chat in which the last message was received (might be the peer if no group involved)</li>
@ -4147,6 +4157,7 @@ sub TelegramBot_BinaryFileWrite($$$) {
<br> <br>
<li>prevMsgId &lt;text&gt;<br>The id of the SECOND last received message is stored in this reading</li> <li>prevMsgId &lt;text&gt;<br>The id of the SECOND last received message is stored in this reading</li>
<li>prevMsgDate &lt;timestamp&gt;<br>The timestamp of the SECOND last received message . g</li>
<li>prevMsgPeer &lt;text&gt;<br>The sender name of the SECOND last received message (either full name or if not available @username)</li> <li>prevMsgPeer &lt;text&gt;<br>The sender name of the SECOND last received message (either full name or if not available @username)</li>
<li>prevMsgPeerId &lt;text&gt;<br>The sender id of the SECOND last received message</li> <li>prevMsgPeerId &lt;text&gt;<br>The sender id of the SECOND last received message</li>
<li>prevMsgText &lt;text&gt;<br>The SECOND last received message text is stored in this reading</li> <li>prevMsgText &lt;text&gt;<br>The SECOND last received message text is stored in this reading</li>