2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 06:39:11 +00:00

50_Signalbot: Fixed issue with Babble and invite

git-svn-id: https://svn.fhem.de/fhem/trunk@25088 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
Adimarantis 2021-10-17 10:03:02 +00:00
parent 09f18dd19b
commit 0836e526dd
2 changed files with 19 additions and 11 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.
- bugfix: 50_Signalbot: Fixed issue with Babble and invite
- bugfix: 73_ElectricityCalculator: use Data:Dumper inserted - bugfix: 73_ElectricityCalculator: use Data:Dumper inserted
- bugfix: 73_GasCalculator: use Data:Dumper inserted - bugfix: 73_GasCalculator: use Data:Dumper inserted
- bugfix: 73_WaterCalculator: use Data:Dumper inserted - bugfix: 73_WaterCalculator: use Data:Dumper inserted

View File

@ -1,6 +1,6 @@
############################################## ##############################################
#$Id$ #$Id$
my $Signalbot_VERSION="3.0"; my $Signalbot_VERSION="3.1";
# Simple Interface to Signal CLI running as Dbus service # Simple Interface to Signal CLI running as Dbus service
# Author: Adimarantis # Author: Adimarantis
# License: GPL # License: GPL
@ -76,7 +76,7 @@ my %sets = (
"isGroupBlocked" => "ay", "isGroupBlocked" => "ay",
"version" => "", "version" => "",
"isMember" => "ay", "isMember" => "ay",
"getAccount" => "", "getSelfNumber" => "", #V0.9.1
# "isRegistered" => "", Removing this will primarily use the register instance, so "true" means -U mode, "false" means multi # "isRegistered" => "", Removing this will primarily use the register instance, so "true" means -U mode, "false" means multi
"sendEndSessionMessage" => "as", #unused "sendEndSessionMessage" => "as", #unused
"sendRemoteDeleteMessage" => "xas", #unused "sendRemoteDeleteMessage" => "xas", #unused
@ -129,7 +129,7 @@ sub Signalbot_Initialize($) {
"registerMethod:SMS,Voice ". "registerMethod:SMS,Voice ".
"$readingFnAttributes"; "$readingFnAttributes";
} }
################################### Todo: Set or Attribute for Mode? Other sets needed? ###################################
sub Signalbot_Set($@) { # sub Signalbot_Set($@) { #
my ( $hash, $name, @args ) = @_; my ( $hash, $name, @args ) = @_;
@ -681,9 +681,9 @@ sub Signalbot_MessageReceived ($@) {
#Just pick one sender in den Priority: group, named contact, number, babblePeer #Just pick one sender in den Priority: group, named contact, number, babblePeer
my $replyPeer=undef; my $replyPeer=undef;
$replyPeer=$sourceRegex if defined $sourceRegex; $replyPeer=$sourceRegex if (defined $sourceRegex and $sourceRegex ne "");
$replyPeer=$senderRegex if defined $senderRegex; $replyPeer=$senderRegex if (defined $senderRegex and $senderRegex ne "");
$replyPeer="#".$groupIdRegex if defined $groupIdRegex; $replyPeer="#".$groupIdRegex if (defined $groupIdRegex and $groupIdRegex ne "");
#Activate Babble integration, only if sender or sender group is in babblePeer #Activate Babble integration, only if sender or sender group is in babblePeer
if (defined $bDevice && defined $bPeer && defined $replyPeer) { if (defined $bDevice && defined $bPeer && defined $replyPeer) {
@ -836,8 +836,8 @@ sub Signalbot_setup2($@) {
if ($state) { if ($state) {
#if running daemon is running in -u mode set the signal path to default regardless of the registered number #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'; $hash->{helper}{signalpath}='/org/asamk/Signal';
$account=Signalbot_CallS($hash,"getAccount"); $account=Signalbot_CallS($hash,"getSelfNumber"); #Available from signal-cli 0.9.1
#Workaround since signal-cli 0.9.0 did not include by getName() method - delete the reading, so its not confusing #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"); } if (!defined $account) { readingsDelete($hash,"account"); }
#Remove all entries that are only available in registration or multi mode #Remove all entries that are only available in registration or multi mode
delete($gets{accounts}); delete($gets{accounts});
@ -1049,8 +1049,10 @@ sub Signalbot_Call($@) {
#Handle Error here and mark Serial for mainloop to ignore #Handle Error here and mark Serial for mainloop to ignore
my $b=$msg->get_body()->[0]; my $b=$msg->get_body()->[0];
readingsSingleUpdate($hash, 'lastError', "Error in $function:".$b,1); readingsSingleUpdate($hash, 'lastError', "Error in $function:".$b,1);
return;
} }
); );
return undef;
} }
sub Signalbot_Read($@){ sub Signalbot_Read($@){
@ -1187,15 +1189,16 @@ sub Signalbot_invite($@) {
while (@contacts) { while (@contacts) {
my $contact=shift @contacts; my $contact=shift @contacts;
my $number=Signalbot_translateContact($hash,$contact); my $number=Signalbot_translateContact($hash,$contact);
return "Unknown Contact" unless defined $number; return "Unknown Contact $contact" unless defined $number;
push @members,$number; push @members,$number;
} }
my @group=Signalbot_getGroup($hash,$groupname); my @group=Signalbot_getGroup($hash,$groupname);
return join(" ",@group) unless @group>1; 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,""); Signalbot_Call($hash,"updateGroup",\@group,"",\@members,"");
return;
} }
sub Signalbot_setBlocked($@) { sub Signalbot_setBlocked($@) {
@ -1372,6 +1375,7 @@ sub Signalbot_Attr(@) { #
my ($command, $name, $attr, $val) = @_; my ($command, $name, $attr, $val) = @_;
my $hash = $defs{$name}; my $hash = $defs{$name};
my $msg = undef; my $msg = undef;
return if !defined $val; #nothing to do when deleting an attribute
Log3 $hash->{NAME}, 5, $hash->{NAME}.": Attr $attr=$val"; Log3 $hash->{NAME}, 5, $hash->{NAME}.": Attr $attr=$val";
if($attr eq "allowedPeer") { if($attr eq "allowedPeer") {
#Take over as is #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<br>"; $ret .= "Note: The installer only supports Debian based Linux distributions like Ubuntu and Raspberry OS<br>";
$ret .= " and X86 or armv7l CPUs<br>"; $ret .= " and X86 or armv7l CPUs<br>";
} }
if($hash->{helper}{version}==901) {
$ret .= "<b>Warning: signal-cli v0.9.1 has issues affecting Signalbot.</b><br>Please use installer to downgrade to 0.9.0<br>";
}
if ($multi==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)<br>"; $ret .= "Signal-cli is running in single-mode, please consider starting it without -u parameter (e.g. by re-running the installer)<br>";
} }
@ -1934,7 +1941,7 @@ For German documentation see <a href="https://wiki.fhem.de/wiki/Signalbot">Wiki<
</li> </li>
<li><b>set invite &ltgroupname&gt &ltcontact&gt</b><br> <li><b>set invite &ltgroupname&gt &ltcontact&gt</b><br>
<a id="Signalbot-set-invite"></a> <a id="Signalbot-set-invite"></a>
Invite new members to an existing group.<br> Invite new members to an existing group. You can add multiple contacts separated by space.<br>
</li> </li>
<a id="Signalbot-set-joinGroup"></a> <a id="Signalbot-set-joinGroup"></a>
<li><b>set joinGroup &ltgroup link&gt</b><br> <li><b>set joinGroup &ltgroup link&gt</b><br>