mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-03 16:56:54 +00:00
50_Signalbot: Added support for unicode textformatting and emoticons
git-svn-id: https://svn.fhem.de/fhem/trunk@25638 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
885d68d66b
commit
5f2c9b0ae5
@ -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.
|
||||||
|
- feature: 50_Signalbot: text formatting and emoticons via unicode
|
||||||
- feature: 70_ESCVP21net.pm: toggle, TW7400, new Readings
|
- feature: 70_ESCVP21net.pm: toggle, TW7400, new Readings
|
||||||
- new: lib/FHEM/Text/Unicode: apply text styles in Unicode
|
- new: lib/FHEM/Text/Unicode: apply text styles in Unicode
|
||||||
- feature: 66_EseraMulti: added support for solar sensor Esera 11112
|
- feature: 66_EseraMulti: added support for solar sensor Esera 11112
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
##############################################
|
##############################################
|
||||||
#$Id$
|
#$Id$
|
||||||
my $Signalbot_VERSION="3.6";
|
my $Signalbot_VERSION="3.7";
|
||||||
# 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
|
||||||
@ -27,6 +27,9 @@ use HttpUtils;
|
|||||||
eval "use Protocol::DBus;1";
|
eval "use Protocol::DBus;1";
|
||||||
eval "use Protocol::DBus::Client;1" or my $DBus_missing = "yes";
|
eval "use Protocol::DBus::Client;1" or my $DBus_missing = "yes";
|
||||||
|
|
||||||
|
require FHEM::Text::Unicode;
|
||||||
|
use FHEM::Text::Unicode qw(:ALL);
|
||||||
|
|
||||||
#maybe really get introspective here instead of handwritten list
|
#maybe really get introspective here instead of handwritten list
|
||||||
my %signatures = (
|
my %signatures = (
|
||||||
"setContactBlocked" => "sb",
|
"setContactBlocked" => "sb",
|
||||||
@ -104,6 +107,7 @@ sub Signalbot_Initialize($) {
|
|||||||
"cmdFavorite ".
|
"cmdFavorite ".
|
||||||
"favorites:textField-long ".
|
"favorites:textField-long ".
|
||||||
"autoJoin:yes,no ".
|
"autoJoin:yes,no ".
|
||||||
|
"formatting:none,html,markdown,both ".
|
||||||
"registerMethod:SMS,Voice ".
|
"registerMethod:SMS,Voice ".
|
||||||
"$readingFnAttributes";
|
"$readingFnAttributes";
|
||||||
}
|
}
|
||||||
@ -339,7 +343,7 @@ sub Signalbot_Set($@) { #
|
|||||||
eval { $fullstring=decode_utf8($fullstring); };
|
eval { $fullstring=decode_utf8($fullstring); };
|
||||||
Log3 $hash->{NAME}, 3 , $hash->{NAME}.": Error from decode" if $@;
|
Log3 $hash->{NAME}, 3 , $hash->{NAME}.": Error from decode" if $@;
|
||||||
|
|
||||||
Log3 $hash->{NAME}, 3 , $hash->{NAME}.": Before parse:" . encode_utf8($fullstring) . ":";
|
Log3 $hash->{NAME}, 3 , $hash->{NAME}.": Before parse:" .$fullstring. ":";
|
||||||
my $tmpmessage = $fullstring =~ s/\\n/\x0a/rg;
|
my $tmpmessage = $fullstring =~ s/\\n/\x0a/rg;
|
||||||
my @args=parse_line(' ',0,$tmpmessage);
|
my @args=parse_line(' ',0,$tmpmessage);
|
||||||
|
|
||||||
@ -401,7 +405,7 @@ sub Signalbot_Set($@) { #
|
|||||||
my @newatt;
|
my @newatt;
|
||||||
foreach my $file (@attachments) {
|
foreach my $file (@attachments) {
|
||||||
if ( -e $file ) {
|
if ( -e $file ) {
|
||||||
if (! $file =~ /tmp\/signalbot/) {
|
if ($file=~/^\/tmp\/signalbot.*/ ne 1) {
|
||||||
$file =~ /^.*?\.([^.]*)?$/;
|
$file =~ /^.*?\.([^.]*)?$/;
|
||||||
my $type = $1;
|
my $type = $1;
|
||||||
my $tmpfilename="/tmp/signalbot".gettimeofday().".".$type;
|
my $tmpfilename="/tmp/signalbot".gettimeofday().".".$type;
|
||||||
@ -419,6 +423,10 @@ sub Signalbot_Set($@) { #
|
|||||||
}
|
}
|
||||||
@attachments=@newatt;
|
@attachments=@newatt;
|
||||||
}
|
}
|
||||||
|
#Convert html or markdown to unicode
|
||||||
|
my $format=AttrVal($hash->{NAME},"formatting","none");
|
||||||
|
my $convmsg=formatTextUnicode($format,$message);
|
||||||
|
$message=$convmsg if defined $convmsg;
|
||||||
|
|
||||||
#Send message to individuals (bulk)
|
#Send message to individuals (bulk)
|
||||||
if (@recipients > 0) {
|
if (@recipients > 0) {
|
||||||
@ -452,7 +460,7 @@ sub Signalbot_Get($@) {
|
|||||||
my $account = ReadingsVal($name,"account","none");
|
my $account = ReadingsVal($name,"account","none");
|
||||||
|
|
||||||
if ($cmd eq "?") {
|
if ($cmd eq "?") {
|
||||||
my $gets="favorites:noArg accounts:noArg ";
|
my $gets="favorites:noArg accounts:noArg helpUnicode:noArg ";
|
||||||
$gets.="contacts:all,nonblocked ".
|
$gets.="contacts:all,nonblocked ".
|
||||||
"groups:all,active,nonblocked " if $account ne "none";
|
"groups:all,active,nonblocked " if $account ne "none";
|
||||||
return "Signalbot_Get: Unknown argument $cmd, choose one of ".$gets;
|
return "Signalbot_Get: Unknown argument $cmd, choose one of ".$gets;
|
||||||
@ -464,6 +472,8 @@ sub Signalbot_Get($@) {
|
|||||||
if ($cmd eq "introspective") {
|
if ($cmd eq "introspective") {
|
||||||
my $reply=Signalbot_CallS($hash,"org.freedesktop.DBus.Introspectable.Introspect");
|
my $reply=Signalbot_CallS($hash,"org.freedesktop.DBus.Introspectable.Introspect");
|
||||||
return undef;
|
return undef;
|
||||||
|
} elsif ($cmd eq "helpUnicode") {
|
||||||
|
return demoUnicodeHTML();
|
||||||
} elsif ($cmd eq "accounts") {
|
} elsif ($cmd eq "accounts") {
|
||||||
my $num=Signalbot_getAccounts($hash);
|
my $num=Signalbot_getAccounts($hash);
|
||||||
return "Error in listAccounts" if $num<0;
|
return "Error in listAccounts" if $num<0;
|
||||||
@ -825,7 +835,7 @@ sub Signalbot_MessageReceived ($@) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Log3 $hash->{NAME}, 4, $hash->{NAME}.": Message from $sender : $message processed";
|
Log3 $hash->{NAME}, 4, $hash->{NAME}.": Message from $sender : ".decode_utf8($message)." processed";
|
||||||
} else {
|
} else {
|
||||||
Log3 $hash->{NAME}, 2, $hash->{NAME}.": Ignored message due to allowedPeer by $source:$message";
|
Log3 $hash->{NAME}, 2, $hash->{NAME}.": Ignored message due to allowedPeer by $source:$message";
|
||||||
readingsSingleUpdate($hash, 'lastError', "Ignored message due to allowedPeer by $source:$message",1);
|
readingsSingleUpdate($hash, 'lastError', "Ignored message due to allowedPeer by $source:$message",1);
|
||||||
@ -925,6 +935,8 @@ sub Signalbot_setup($@){
|
|||||||
$hash->{STATE}="Connecting";
|
$hash->{STATE}="Connecting";
|
||||||
Signalbot_fetchFile($hash,"svn.fhem.de","/fhem/trunk/fhem/contrib/signal/signal_install.sh","www/signal/signal_install.sh");
|
Signalbot_fetchFile($hash,"svn.fhem.de","/fhem/trunk/fhem/contrib/signal/signal_install.sh","www/signal/signal_install.sh");
|
||||||
chmod 0755, "www/signal/signal_install.sh";
|
chmod 0755, "www/signal/signal_install.sh";
|
||||||
|
#Make sure Logfile looks ok with Unicode characters and does not raise "Wide character"
|
||||||
|
binmode(LOG,"encoding(UTF-8)");
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1424,7 +1436,7 @@ sub Signalbot_refreshGroups($@) {
|
|||||||
|
|
||||||
sub Signalbot_sendMessage($@) {
|
sub Signalbot_sendMessage($@) {
|
||||||
my ( $hash,$rec,$att,$mes ) = @_;
|
my ( $hash,$rec,$att,$mes ) = @_;
|
||||||
Log3 $hash->{NAME}, 4, $hash->{NAME}.": sendMessage called for $rec:$att:".encode_utf8($mes);
|
Log3 $hash->{NAME}, 4, $hash->{NAME}.": sendMessage called for $rec:$att:".$mes;
|
||||||
|
|
||||||
my @recorg= split(/,/,$rec);
|
my @recorg= split(/,/,$rec);
|
||||||
my @attach=split(/,/,$att);
|
my @attach=split(/,/,$att);
|
||||||
@ -2098,7 +2110,6 @@ sub Signalbot_OSRel() {
|
|||||||
# -2 for Audio
|
# -2 for Audio
|
||||||
# -3 for other media
|
# -3 for other media
|
||||||
# and extension without dot as 2nd list element
|
# and extension without dot as 2nd list element
|
||||||
|
|
||||||
sub Signalbot_IdentifyStream($$) {
|
sub Signalbot_IdentifyStream($$) {
|
||||||
my ($hash, $msg) = @_;
|
my ($hash, $msg) = @_;
|
||||||
|
|
||||||
@ -2286,6 +2297,11 @@ For German documentation see <a href="https://wiki.fhem.de/wiki/Signalbot">Wiki<
|
|||||||
<a id="Signalbot-get-favorites"></a>
|
<a id="Signalbot-get-favorites"></a>
|
||||||
Lists the defined favorites in the attribute "favorites" in a readable format<br>
|
Lists the defined favorites in the attribute "favorites" in a readable format<br>
|
||||||
</li>
|
</li>
|
||||||
|
<li><b>get helpUnicode</b><br>
|
||||||
|
<a id="Signalbot-get-helpUnicode"></a>
|
||||||
|
Opens a cheat sheet for all supported replacements to format text or add emoticons using html-like tags or markdown.<br>
|
||||||
|
<b>Note:</b> This functionality needs to be enabled using the "formatting" attribute.<br>
|
||||||
|
</li>
|
||||||
<br>
|
<br>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
@ -2367,6 +2383,17 @@ For German documentation see <a href="https://wiki.fhem.de/wiki/Signalbot">Wiki<
|
|||||||
<a id="Signalbot-attr-defaultPeer"></a>
|
<a id="Signalbot-attr-defaultPeer"></a>
|
||||||
If <b>send</b> is used without a recipient, the message will send to this account or group(with #)<br>
|
If <b>send</b> is used without a recipient, the message will send to this account or group(with #)<br>
|
||||||
</li>
|
</li>
|
||||||
|
<li><b>formatting</b><br>
|
||||||
|
<a id="Signalbot-attr-formatting"></a>
|
||||||
|
The "formatting" attribute has the following four options that allow highlighting in Unicode:
|
||||||
|
<ul>
|
||||||
|
<li>none - no replacements </li>
|
||||||
|
<li>html - replacements are enabled here with HTML-type tags (e.g. for bold <b> is bold </b>)</li>
|
||||||
|
<li>markdown - replacements are enabled by markdown-like tags (e.g. __for italic__) as well as emotics</li>
|
||||||
|
<li>both - both methods are possible here</li>
|
||||||
|
</ul>
|
||||||
|
To learn about the syntax how to use tags and markdown, use the get helpUnicode method. You can still also simply copy&paste Unicode text from other sources.
|
||||||
|
</li>
|
||||||
<br>
|
<br>
|
||||||
</ul>
|
</ul>
|
||||||
<br>
|
<br>
|
||||||
|
@ -626,6 +626,7 @@ lib/FHEM/Core/Timer/Register.pm Beta-User FHEM Development
|
|||||||
lib/FHEM/SynoModules/API.pm DS_Starter Sonstiges
|
lib/FHEM/SynoModules/API.pm DS_Starter Sonstiges
|
||||||
lib/FHEM/SynoModules/SMUtils.pm DS_Starter Sonstiges
|
lib/FHEM/SynoModules/SMUtils.pm DS_Starter Sonstiges
|
||||||
lib/FHEM/SynoModules/ErrCodes.pm DS_Starter Sonstiges
|
lib/FHEM/SynoModules/ErrCodes.pm DS_Starter Sonstiges
|
||||||
|
lib/FHEM/Text/Unicode.pm Adimarantis FHEM Development
|
||||||
|
|
||||||
contrib/sacha_gloor/* rudolfkoenig/orphan Sonstiges
|
contrib/sacha_gloor/* rudolfkoenig/orphan Sonstiges
|
||||||
contrib/70_ONKYO_AVR_PULL.pm loredo (deprecated)
|
contrib/70_ONKYO_AVR_PULL.pm loredo (deprecated)
|
||||||
|
@ -74,8 +74,8 @@ my @mtags = (
|
|||||||
# markdown: Only apply Markdown formatting like __text__ and emoticon replacements
|
# markdown: Only apply Markdown formatting like __text__ and emoticon replacements
|
||||||
# both: Apply both formatting styles
|
# both: Apply both formatting styles
|
||||||
#$msg: ASCII String that should be replaced
|
#$msg: ASCII String that should be replaced
|
||||||
#return: Unicode string with applied replacements
|
#returns: Unicode string with applied replacements
|
||||||
#To display all replacements use the demoUnicode() pr demoUnicodeHTML() function
|
#To display all replacements use the demoUnicode() or demoUnicodeHTML() function
|
||||||
sub formatTextUnicode($$) {
|
sub formatTextUnicode($$) {
|
||||||
my ($format,$msg) = @_;
|
my ($format,$msg) = @_;
|
||||||
my @tags;
|
my @tags;
|
||||||
@ -147,7 +147,9 @@ sub formatStringUnicode($$) {
|
|||||||
|
|
||||||
my $rep=chr($uc{$font}[0])."-".chr($uc{$font}[0]+25).chr($uc{$font}[1])."-".chr($uc{$font}[1]+25).chr($uc{$font}[2])."-".chr($uc{$font}[2]+9);
|
my $rep=chr($uc{$font}[0])."-".chr($uc{$font}[0]+25).chr($uc{$font}[1])."-".chr($uc{$font}[1]+25).chr($uc{$font}[2])."-".chr($uc{$font}[2]+9);
|
||||||
$_=$str;
|
$_=$str;
|
||||||
eval "tr/a-zA-Z0-9/$rep/";
|
#"no warnings" to prevent a bug in older Perl versions (seen in 5.28) that warns about
|
||||||
|
#"Replacement list is longer than search list" when using ASCII->Unicode replacements
|
||||||
|
eval "{no warnings; tr/a-zA-Z0-9/$rep/}";
|
||||||
return undef if $@;
|
return undef if $@;
|
||||||
#Special handling for characters missing in some fonts
|
#Special handling for characters missing in some fonts
|
||||||
# 0x1d455 => 0x1d629, #italic h -> italic sans-serif h or 0x210e (planck constant)
|
# 0x1d455 => 0x1d629, #italic h -> italic sans-serif h or 0x210e (planck constant)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user