new(basic.gblib): New SET WHOLE WORD keyword added.
This commit is contained in:
parent
eacd933b05
commit
88a63710c0
4 changed files with 61 additions and 41 deletions
|
@ -343,6 +343,19 @@ export class DialogKeywords {
|
|||
this.user = user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the FIND behaviour to consider whole words while searching.
|
||||
*
|
||||
* @example SET WHOLE WORD ON
|
||||
*
|
||||
*/
|
||||
public async setWholeWord(step, on) {
|
||||
const user = await this.min.userProfile.get(step.context, {});
|
||||
user.basicOptions.wholeWord = (on.trim() === "on");
|
||||
await this.min.userProfile.set(step.context, user);
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines translator behaviour.
|
||||
*
|
||||
|
|
|
@ -457,8 +457,19 @@ export class SystemKeywords {
|
|||
case 'string':
|
||||
switch (filter.operator) {
|
||||
case '=':
|
||||
if (result && result.toLowerCase().trim() === filter.value.toLowerCase().trim()) {
|
||||
filterAcceptCount++;
|
||||
let wholeWord = true;
|
||||
if (this.dk.user && this.dk.user.basicOptions && this.dk.user.basicOptions.wholeWord) {
|
||||
wholeWord = this.dk.user.basicOptions.wholeWord;
|
||||
}
|
||||
if (wholeWord) {
|
||||
if (result && result.toLowerCase().trim() === filter.value.toLowerCase().trim()) {
|
||||
filterAcceptCount++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (result && result.toLowerCase().trim().indexOf(filter.value.toLowerCase().trim()) > -1) {
|
||||
filterAcceptCount++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'not in':
|
||||
|
|
|
@ -812,11 +812,14 @@ export class GBMinService {
|
|||
|
||||
const sec = new SecService();
|
||||
if (!user.loaded) {
|
||||
|
||||
await min.conversationalService.sendEvent(min, step, 'loadInstance', {});
|
||||
|
||||
user.loaded = true;
|
||||
user.subjects = [];
|
||||
user.cb = undefined;
|
||||
user.welcomed = false;
|
||||
user.basicOptions = { maxLines: 100, translatorOn: true };
|
||||
user.basicOptions = { maxLines: 100, translatorOn: true , wholeWord: true};
|
||||
|
||||
firstTime = true;
|
||||
|
||||
|
@ -888,6 +891,7 @@ export class GBMinService {
|
|||
|
||||
// Answer to specific BOT Framework event conversationUpdate to auto start dialogs.
|
||||
// Skips if the bot is talking.
|
||||
const startDialog = min.core.getParam(min.instance, 'Start Dialog', null);
|
||||
|
||||
if (context.activity.type === 'conversationUpdate' &&
|
||||
context.activity.membersAdded.length > 0) {
|
||||
|
@ -906,19 +910,22 @@ export class GBMinService {
|
|||
|
||||
// Auto starts dialogs if any is specified.
|
||||
|
||||
const startDialog = min.core.getParam(min.instance, 'Start Dialog', null);
|
||||
if (!startDialog && !user.welcomed) {
|
||||
|
||||
// Otherwise, calls / (root) to default welcome users.
|
||||
|
||||
await step.beginDialog('/');
|
||||
}
|
||||
else {
|
||||
user.welcomed = true;
|
||||
GBLog.info(`Auto start (web) dialog is now being called: ${startDialog} for ${min.instance.instanceId}...`);
|
||||
await GBVMService.callVM(startDialog.toLowerCase(), min, step, this.deployer);
|
||||
}
|
||||
|
||||
} else {
|
||||
GBLog.info(`Person added to conversation: ${member.name}`);
|
||||
|
||||
if (this.userMobile(step)) {
|
||||
const startDialog = min.core.getParam(min.instance, 'Start Dialog', null);
|
||||
if (this.userMobile(step) ) {
|
||||
if (startDialog && !user.welcomed) {
|
||||
user.welcomed = true;
|
||||
GBLog.info(`Auto start (whatsapp) dialog is now being called: ${startDialog} for ${min.instance.instanceId}...`);
|
||||
|
|
|
@ -77,15 +77,17 @@ class GBUIApp extends React.Component {
|
|||
}
|
||||
|
||||
send(command) {
|
||||
window.line
|
||||
.postActivity({
|
||||
type: 'event',
|
||||
name: command,
|
||||
locale: 'en-us',
|
||||
textFormat: 'plain',
|
||||
timestamp: new Date().toISOString(),
|
||||
from: this.getUser()
|
||||
});
|
||||
|
||||
window.line
|
||||
.postActivity({
|
||||
type: 'event',
|
||||
name: command,
|
||||
locale: 'en-us',
|
||||
textFormat: 'plain',
|
||||
timestamp: new Date().toISOString(),
|
||||
from: this.getUser()
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
getUser() {
|
||||
|
@ -93,19 +95,6 @@ class GBUIApp extends React.Component {
|
|||
return { id: 'web@gb', name: 'You' };
|
||||
}
|
||||
|
||||
postEvent(name, item) {
|
||||
setTimeout(() => {
|
||||
window['botConnection'].postActivity({
|
||||
type: "event",
|
||||
name: name,
|
||||
data: item,
|
||||
locale: "en-us",
|
||||
textFormat: "plain",
|
||||
timestamp: new Date().toISOString(),
|
||||
from: window.user
|
||||
})
|
||||
}, 400);
|
||||
}
|
||||
postMessage(value) {
|
||||
window.line.postActivity({
|
||||
type: 'message',
|
||||
|
@ -162,7 +151,7 @@ class GBUIApp extends React.Component {
|
|||
window.userAgentApplication = userAgentApplication;
|
||||
|
||||
if (!userAgentApplication.isCallback(window.location.hash) && window.parent === window
|
||||
&& !window.opener && userAgentApplication.getUser) {
|
||||
&& !window.opener && userAgentApplication.getUser) {
|
||||
var user = userAgentApplication.getUser();
|
||||
if (user) {
|
||||
userAgentApplication.acquireTokenSilent(graphScopes).then(
|
||||
|
@ -184,25 +173,25 @@ class GBUIApp extends React.Component {
|
|||
const line = new DirectLine({
|
||||
token: instanceClient.webchatToken
|
||||
});
|
||||
_this_.setState({ line: line});
|
||||
_this_.setState({ line: line });
|
||||
|
||||
line.connectionStatus$.subscribe(connectionStatus => {
|
||||
if (connectionStatus === ConnectionStatus.Online) {
|
||||
_this_.setState({ instanceClient: instanceClient});
|
||||
window['botConnection'] = line;
|
||||
_this_.setState({ instanceClient: instanceClient });
|
||||
window['botConnection'] = line;
|
||||
}
|
||||
});
|
||||
|
||||
window.line = line;
|
||||
|
||||
line.activity$
|
||||
.filter(activity => activity.type === 'event' && activity.name === 'loadInstance')
|
||||
.subscribe(() => {
|
||||
this.postEvent('startGB', true);
|
||||
_this_.authenticate();
|
||||
});
|
||||
.filter(activity => activity.type === 'event' && activity.name === 'loadInstance')
|
||||
.subscribe(() => {
|
||||
_this_.send('startGB');
|
||||
_this_.authenticate();
|
||||
});
|
||||
|
||||
line.activity$
|
||||
line.activity$
|
||||
.filter(activity => activity.type === 'event' && activity.name === 'stop')
|
||||
.subscribe(() => {
|
||||
if (_this_.player) {
|
||||
|
@ -322,7 +311,7 @@ class GBUIApp extends React.Component {
|
|||
seo = <SEO instance={this.state.instanceClient} />;
|
||||
}
|
||||
|
||||
// let speechOptions;
|
||||
// let speechOptions;
|
||||
// let token = this.state.instanceClient.speechToken;
|
||||
|
||||
// speechOptions = {
|
||||
|
|
Loading…
Add table
Reference in a new issue