mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-16 04:36:02 +00:00
95_Babble.pm: Bugfix
git-svn-id: https://svn.fhem.de/fhem/trunk@16287 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
18ae981691
commit
41dc11f7f0
@ -53,7 +53,7 @@ if (eval {require RiveScript;1;} ne 1) {
|
|||||||
my $babblelinkname = "babbles"; # link text
|
my $babblelinkname = "babbles"; # link text
|
||||||
my $babblehiddenroom = "babbleRoom"; # hidden room
|
my $babblehiddenroom = "babbleRoom"; # hidden room
|
||||||
my $babblepublicroom = "babble"; # public room
|
my $babblepublicroom = "babble"; # public room
|
||||||
my $babbleversion = "1.26";
|
my $babbleversion = "1.31";
|
||||||
|
|
||||||
my %babble_transtable_EN = (
|
my %babble_transtable_EN = (
|
||||||
"ok" => "OK",
|
"ok" => "OK",
|
||||||
@ -183,7 +183,7 @@ sub Babble_Initialize ($) {
|
|||||||
$hash->{GetFn} = "Babble_Get";
|
$hash->{GetFn} = "Babble_Get";
|
||||||
$hash->{UndefFn} = "Babble_Undef";
|
$hash->{UndefFn} = "Babble_Undef";
|
||||||
#$hash->{AttrFn} = "Babble_Attr";
|
#$hash->{AttrFn} = "Babble_Attr";
|
||||||
my $attst = "lockstate:locked,unlocked helpFunc confirmFunc noChatBot:0,1 testParm0 testParm1 testParm2 testParm3 ".
|
my $attst = "lockstate:locked,unlocked helpFunc confirmFunc noChatBot:0,1 dnuFile testParm0 testParm1 testParm2 testParm3 ".
|
||||||
"remoteFHEM0 remoteFHEM1 remoteFHEM2 remoteFHEM3 remoteFunc0 remoteFunc1 remoteFunc2 remoteFunc3 remoteToken0 remoteToken1 remoteToken2 remoteToken3 ".
|
"remoteFHEM0 remoteFHEM1 remoteFHEM2 remoteFHEM3 remoteFunc0 remoteFunc1 remoteFunc2 remoteFunc3 remoteToken0 remoteToken1 remoteToken2 remoteToken3 ".
|
||||||
"babbleIds babblePreSubs babbleDevices babblePlaces babbleNotPlaces babbleVerbs babbleVerbParts babblePrepos babbleQuests babbleArticles babbleStatus babbleWrites babbleTimes";
|
"babbleIds babblePreSubs babbleDevices babblePlaces babbleNotPlaces babbleVerbs babbleVerbParts babblePrepos babbleQuests babbleArticles babbleStatus babbleWrites babbleTimes";
|
||||||
$hash->{AttrList} = $attst;
|
$hash->{AttrList} = $attst;
|
||||||
@ -1100,7 +1100,7 @@ sub Babble_DoIt{
|
|||||||
$reading = "none"
|
$reading = "none"
|
||||||
if( !$reading );
|
if( !$reading );
|
||||||
|
|
||||||
if( defined(@parms) && $parms[0] eq "testit"){
|
if( @parms && $parms[0] eq "testit"){
|
||||||
$testit = 1;
|
$testit = 1;
|
||||||
shift @parms;
|
shift @parms;
|
||||||
$exflag = $parms[0];
|
$exflag = $parms[0];
|
||||||
@ -1190,6 +1190,7 @@ sub Babble_DoIt{
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#-- confirm execution
|
#-- confirm execution
|
||||||
my $func = AttrVal($name,"confirmFunc",undef);
|
my $func = AttrVal($name,"confirmFunc",undef);
|
||||||
if( $confirm ){
|
if( $confirm ){
|
||||||
@ -1202,7 +1203,7 @@ sub Babble_DoIt{
|
|||||||
}
|
}
|
||||||
$res = fhem($func);
|
$res = fhem($func);
|
||||||
}else{
|
}else{
|
||||||
Log3 $name,1,"[Babble_DoIt] requesting confirmation, but no attribute confirmFunc defined";
|
Log3 $name,1,"[Babble_DoIt] Warning: requesting confirmation, but no attribute confirmFunc defined";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1223,8 +1224,18 @@ sub Babble_DoIt{
|
|||||||
if( !defined($hash->{Rive}) );
|
if( !defined($hash->{Rive}) );
|
||||||
my $rs = $hash->{Rive};
|
my $rs = $hash->{Rive};
|
||||||
$reply = $rs->reply ('localuser',$sentence);
|
$reply = $rs->reply ('localuser',$sentence);
|
||||||
$reply = $babble_tt->{dnu}
|
if ($reply eq "ERR: No Reply Matched"){
|
||||||
if ($reply eq "ERR: No Reply Matched");
|
$reply = $babble_tt->{dnu};
|
||||||
|
my $dnufile = AttrVal($name,"dnuFile",undef);
|
||||||
|
if( $dnufile ){
|
||||||
|
open(my $fh, '>>', $dnufile);
|
||||||
|
print $fh $sentence." => Category=$cat: ".
|
||||||
|
$babble_tt->{"device"}."=$device ".$babble_tt->{"place"}."=$place ".
|
||||||
|
$babble_tt->{"verb"}."=$verb ".$babble_tt->{"target"}."=$reading / $value\n";
|
||||||
|
close $fh;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#-- no chatbot, use help text directly
|
#-- no chatbot, use help text directly
|
||||||
}else{
|
}else{
|
||||||
$reply = defined($hash->{DATA}{"help"}{$device}) ? $hash->{DATA}{"help"}{$device} : "";
|
$reply = defined($hash->{DATA}{"help"}{$device}) ? $hash->{DATA}{"help"}{$device} : "";
|
||||||
@ -2176,7 +2187,9 @@ sub Babble_Html($)
|
|||||||
will be replaced by the devicename identified by Babble, the help text for this device and parameters passed to the Babble_DoIt function</li>
|
will be replaced by the devicename identified by Babble, the help text for this device and parameters passed to the Babble_DoIt function</li>
|
||||||
<li><a name="testParm"><code>attr <name> testParm(0|1|2|3) <string&rt;</code></a>
|
<li><a name="testParm"><code>attr <name> testParm(0|1|2|3) <string&rt;</code></a>
|
||||||
<br/>if a command is not really excuted, but only tested, the values of these attributes will be used to substitute the strings $PARM[0|1|2...]
|
<br/>if a command is not really excuted, but only tested, the values of these attributes will be used to substitute the strings $PARM[0|1|2...]
|
||||||
in the tested command</li>
|
in the tested command</li>
|
||||||
|
<li><a name="dnuFile"><code>attr <name> dnuFile <filename&rt;</code></a>
|
||||||
|
<br/>if this filename is given, every sentence that could not be analyzed is stored in this file</li>
|
||||||
<li><a name="confirmFunc"><code>attr <name> confirmFunc <function name&rt;</code></a>
|
<li><a name="confirmFunc"><code>attr <name> confirmFunc <function name&rt;</code></a>
|
||||||
<br/>name of a confirmation function which is used in case a command is exceuted. When this function is called, the strings $DEV, $HELP, $PARM[0|1|2...]
|
<br/>name of a confirmation function which is used in case a command is exceuted. When this function is called, the strings $DEV, $HELP, $PARM[0|1|2...]
|
||||||
will be replaced by the devicename identified by Babble, the help text for this device and parameters passed to the Babble_DoIt function</li>
|
will be replaced by the devicename identified by Babble, the help text for this device and parameters passed to the Babble_DoIt function</li>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user