From 0836e526dde86d8598eb9151e843a55acbbf09c7 Mon Sep 17 00:00:00 2001
From: Adimarantis <>
Date: Sun, 17 Oct 2021 10:03:02 +0000
Subject: [PATCH] 50_Signalbot: Fixed issue with Babble and invite
git-svn-id: https://svn.fhem.de/fhem/trunk@25088 2b470e98-0d58-463d-a4d8-8e2adae1ed80
---
fhem/CHANGED | 1 +
fhem/FHEM/50_Signalbot.pm | 29 ++++++++++++++++++-----------
2 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/fhem/CHANGED b/fhem/CHANGED
index f4b1cf02f..11092bc10 100644
--- a/fhem/CHANGED
+++ b/fhem/CHANGED
@@ -1,5 +1,6 @@
# 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.
+ - bugfix: 50_Signalbot: Fixed issue with Babble and invite
- bugfix: 73_ElectricityCalculator: use Data:Dumper inserted
- bugfix: 73_GasCalculator: use Data:Dumper inserted
- bugfix: 73_WaterCalculator: use Data:Dumper inserted
diff --git a/fhem/FHEM/50_Signalbot.pm b/fhem/FHEM/50_Signalbot.pm
index 6ee53878f..a7064e9d0 100755
--- a/fhem/FHEM/50_Signalbot.pm
+++ b/fhem/FHEM/50_Signalbot.pm
@@ -1,6 +1,6 @@
##############################################
#$Id$
-my $Signalbot_VERSION="3.0";
+my $Signalbot_VERSION="3.1";
# Simple Interface to Signal CLI running as Dbus service
# Author: Adimarantis
# License: GPL
@@ -76,7 +76,7 @@ my %sets = (
"isGroupBlocked" => "ay",
"version" => "",
"isMember" => "ay",
- "getAccount" => "",
+ "getSelfNumber" => "", #V0.9.1
# "isRegistered" => "", Removing this will primarily use the register instance, so "true" means -U mode, "false" means multi
"sendEndSessionMessage" => "as", #unused
"sendRemoteDeleteMessage" => "xas", #unused
@@ -129,7 +129,7 @@ sub Signalbot_Initialize($) {
"registerMethod:SMS,Voice ".
"$readingFnAttributes";
}
-################################### Todo: Set or Attribute for Mode? Other sets needed?
+###################################
sub Signalbot_Set($@) { #
my ( $hash, $name, @args ) = @_;
@@ -681,9 +681,9 @@ sub Signalbot_MessageReceived ($@) {
#Just pick one sender in den Priority: group, named contact, number, babblePeer
my $replyPeer=undef;
- $replyPeer=$sourceRegex if defined $sourceRegex;
- $replyPeer=$senderRegex if defined $senderRegex;
- $replyPeer="#".$groupIdRegex if defined $groupIdRegex;
+ $replyPeer=$sourceRegex if (defined $sourceRegex and $sourceRegex ne "");
+ $replyPeer=$senderRegex if (defined $senderRegex and $senderRegex ne "");
+ $replyPeer="#".$groupIdRegex if (defined $groupIdRegex and $groupIdRegex ne "");
#Activate Babble integration, only if sender or sender group is in babblePeer
if (defined $bDevice && defined $bPeer && defined $replyPeer) {
@@ -836,8 +836,8 @@ sub Signalbot_setup2($@) {
if ($state) {
#if running daemon is running in -u mode set the signal path to default regardless of the registered number
$hash->{helper}{signalpath}='/org/asamk/Signal';
- $account=Signalbot_CallS($hash,"getAccount");
- #Workaround since signal-cli 0.9.0 did not include by getName() method - delete the reading, so its not confusing
+ $account=Signalbot_CallS($hash,"getSelfNumber"); #Available from signal-cli 0.9.1
+ #Workaround since signal-cli 0.9.0 did not include by getSelfNumber() method - delete the reading, so its not confusing
if (!defined $account) { readingsDelete($hash,"account"); }
#Remove all entries that are only available in registration or multi mode
delete($gets{accounts});
@@ -1049,8 +1049,10 @@ sub Signalbot_Call($@) {
#Handle Error here and mark Serial for mainloop to ignore
my $b=$msg->get_body()->[0];
readingsSingleUpdate($hash, 'lastError', "Error in $function:".$b,1);
+ return;
}
);
+ return undef;
}
sub Signalbot_Read($@){
@@ -1187,15 +1189,16 @@ sub Signalbot_invite($@) {
while (@contacts) {
my $contact=shift @contacts;
my $number=Signalbot_translateContact($hash,$contact);
- return "Unknown Contact" unless defined $number;
+ return "Unknown Contact $contact" unless defined $number;
push @members,$number;
}
my @group=Signalbot_getGroup($hash,$groupname);
return join(" ",@group) unless @group>1;
- Log3 $hash->{NAME}, 4, $hash->{NAME}.": Invited ".join(",",@contacts)." to $groupname";
+ Log3 $hash->{NAME}, 4, $hash->{NAME}.": Invited ".join(",",@members)." to $groupname";
Signalbot_Call($hash,"updateGroup",\@group,"",\@members,"");
+ return;
}
sub Signalbot_setBlocked($@) {
@@ -1372,6 +1375,7 @@ sub Signalbot_Attr(@) { #
my ($command, $name, $attr, $val) = @_;
my $hash = $defs{$name};
my $msg = undef;
+ return if !defined $val; #nothing to do when deleting an attribute
Log3 $hash->{NAME}, 5, $hash->{NAME}.": Attr $attr=$val";
if($attr eq "allowedPeer") {
#Take over as is
@@ -1637,6 +1641,9 @@ sub Signalbot_Detail {
$ret .= "Note: The installer only supports Debian based Linux distributions like Ubuntu and Raspberry OS
";
$ret .= " and X86 or armv7l CPUs
";
}
+ if($hash->{helper}{version}==901) {
+ $ret .= "Warning: signal-cli v0.9.1 has issues affecting Signalbot.
Please use installer to downgrade to 0.9.0
";
+ }
if ($multi==0) {
$ret .= "Signal-cli is running in single-mode, please consider starting it without -u parameter (e.g. by re-running the installer)
";
}
@@ -1934,7 +1941,7 @@ For German documentation see Wiki<
- Invite new members to an existing group.
+ Invite new members to an existing group. You can add multiple contacts separated by space.