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;
|
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.
|
* Defines translator behaviour.
|
||||||
*
|
*
|
||||||
|
|
|
@ -457,8 +457,19 @@ export class SystemKeywords {
|
||||||
case 'string':
|
case 'string':
|
||||||
switch (filter.operator) {
|
switch (filter.operator) {
|
||||||
case '=':
|
case '=':
|
||||||
if (result && result.toLowerCase().trim() === filter.value.toLowerCase().trim()) {
|
let wholeWord = true;
|
||||||
filterAcceptCount++;
|
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;
|
break;
|
||||||
case 'not in':
|
case 'not in':
|
||||||
|
|
|
@ -812,11 +812,14 @@ export class GBMinService {
|
||||||
|
|
||||||
const sec = new SecService();
|
const sec = new SecService();
|
||||||
if (!user.loaded) {
|
if (!user.loaded) {
|
||||||
|
|
||||||
|
await min.conversationalService.sendEvent(min, step, 'loadInstance', {});
|
||||||
|
|
||||||
user.loaded = true;
|
user.loaded = true;
|
||||||
user.subjects = [];
|
user.subjects = [];
|
||||||
user.cb = undefined;
|
user.cb = undefined;
|
||||||
user.welcomed = false;
|
user.welcomed = false;
|
||||||
user.basicOptions = { maxLines: 100, translatorOn: true };
|
user.basicOptions = { maxLines: 100, translatorOn: true , wholeWord: true};
|
||||||
|
|
||||||
firstTime = true;
|
firstTime = true;
|
||||||
|
|
||||||
|
@ -888,6 +891,7 @@ export class GBMinService {
|
||||||
|
|
||||||
// Answer to specific BOT Framework event conversationUpdate to auto start dialogs.
|
// Answer to specific BOT Framework event conversationUpdate to auto start dialogs.
|
||||||
// Skips if the bot is talking.
|
// Skips if the bot is talking.
|
||||||
|
const startDialog = min.core.getParam(min.instance, 'Start Dialog', null);
|
||||||
|
|
||||||
if (context.activity.type === 'conversationUpdate' &&
|
if (context.activity.type === 'conversationUpdate' &&
|
||||||
context.activity.membersAdded.length > 0) {
|
context.activity.membersAdded.length > 0) {
|
||||||
|
@ -906,19 +910,22 @@ export class GBMinService {
|
||||||
|
|
||||||
// Auto starts dialogs if any is specified.
|
// Auto starts dialogs if any is specified.
|
||||||
|
|
||||||
const startDialog = min.core.getParam(min.instance, 'Start Dialog', null);
|
|
||||||
if (!startDialog && !user.welcomed) {
|
if (!startDialog && !user.welcomed) {
|
||||||
|
|
||||||
// Otherwise, calls / (root) to default welcome users.
|
// Otherwise, calls / (root) to default welcome users.
|
||||||
|
|
||||||
await step.beginDialog('/');
|
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 {
|
} else {
|
||||||
GBLog.info(`Person added to conversation: ${member.name}`);
|
GBLog.info(`Person added to conversation: ${member.name}`);
|
||||||
|
|
||||||
if (this.userMobile(step)) {
|
if (this.userMobile(step) ) {
|
||||||
const startDialog = min.core.getParam(min.instance, 'Start Dialog', null);
|
|
||||||
if (startDialog && !user.welcomed) {
|
if (startDialog && !user.welcomed) {
|
||||||
user.welcomed = true;
|
user.welcomed = true;
|
||||||
GBLog.info(`Auto start (whatsapp) dialog is now being called: ${startDialog} for ${min.instance.instanceId}...`);
|
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) {
|
send(command) {
|
||||||
window.line
|
|
||||||
.postActivity({
|
window.line
|
||||||
type: 'event',
|
.postActivity({
|
||||||
name: command,
|
type: 'event',
|
||||||
locale: 'en-us',
|
name: command,
|
||||||
textFormat: 'plain',
|
locale: 'en-us',
|
||||||
timestamp: new Date().toISOString(),
|
textFormat: 'plain',
|
||||||
from: this.getUser()
|
timestamp: new Date().toISOString(),
|
||||||
});
|
from: this.getUser()
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getUser() {
|
getUser() {
|
||||||
|
@ -93,19 +95,6 @@ class GBUIApp extends React.Component {
|
||||||
return { id: 'web@gb', name: 'You' };
|
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) {
|
postMessage(value) {
|
||||||
window.line.postActivity({
|
window.line.postActivity({
|
||||||
type: 'message',
|
type: 'message',
|
||||||
|
@ -161,8 +150,8 @@ class GBUIApp extends React.Component {
|
||||||
);
|
);
|
||||||
window.userAgentApplication = userAgentApplication;
|
window.userAgentApplication = userAgentApplication;
|
||||||
|
|
||||||
if (!userAgentApplication.isCallback(window.location.hash) && window.parent === window
|
if (!userAgentApplication.isCallback(window.location.hash) && window.parent === window
|
||||||
&& !window.opener && userAgentApplication.getUser) {
|
&& !window.opener && userAgentApplication.getUser) {
|
||||||
var user = userAgentApplication.getUser();
|
var user = userAgentApplication.getUser();
|
||||||
if (user) {
|
if (user) {
|
||||||
userAgentApplication.acquireTokenSilent(graphScopes).then(
|
userAgentApplication.acquireTokenSilent(graphScopes).then(
|
||||||
|
@ -184,25 +173,25 @@ class GBUIApp extends React.Component {
|
||||||
const line = new DirectLine({
|
const line = new DirectLine({
|
||||||
token: instanceClient.webchatToken
|
token: instanceClient.webchatToken
|
||||||
});
|
});
|
||||||
_this_.setState({ line: line});
|
_this_.setState({ line: line });
|
||||||
|
|
||||||
line.connectionStatus$.subscribe(connectionStatus => {
|
line.connectionStatus$.subscribe(connectionStatus => {
|
||||||
if (connectionStatus === ConnectionStatus.Online) {
|
if (connectionStatus === ConnectionStatus.Online) {
|
||||||
_this_.setState({ instanceClient: instanceClient});
|
_this_.setState({ instanceClient: instanceClient });
|
||||||
window['botConnection'] = line;
|
window['botConnection'] = line;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
window.line = line;
|
window.line = line;
|
||||||
|
|
||||||
line.activity$
|
line.activity$
|
||||||
.filter(activity => activity.type === 'event' && activity.name === 'loadInstance')
|
.filter(activity => activity.type === 'event' && activity.name === 'loadInstance')
|
||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
this.postEvent('startGB', true);
|
_this_.send('startGB');
|
||||||
_this_.authenticate();
|
_this_.authenticate();
|
||||||
});
|
});
|
||||||
|
|
||||||
line.activity$
|
line.activity$
|
||||||
.filter(activity => activity.type === 'event' && activity.name === 'stop')
|
.filter(activity => activity.type === 'event' && activity.name === 'stop')
|
||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
if (_this_.player) {
|
if (_this_.player) {
|
||||||
|
@ -317,12 +306,12 @@ class GBUIApp extends React.Component {
|
||||||
if (this.state.line) {
|
if (this.state.line) {
|
||||||
|
|
||||||
if (this.state.instanceClient) {
|
if (this.state.instanceClient) {
|
||||||
|
|
||||||
gbCss = <GBCss instance={this.state.instanceClient} />;
|
gbCss = <GBCss instance={this.state.instanceClient} />;
|
||||||
seo = <SEO instance={this.state.instanceClient} />;
|
seo = <SEO instance={this.state.instanceClient} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
// let speechOptions;
|
// let speechOptions;
|
||||||
// let token = this.state.instanceClient.speechToken;
|
// let token = this.state.instanceClient.speechToken;
|
||||||
|
|
||||||
// speechOptions = {
|
// speechOptions = {
|
||||||
|
|
Loading…
Add table
Reference in a new issue