Merge branch 'main' of https://github.com/GeneralBots/BotServer
This commit is contained in:
commit
ca4a5e06be
3 changed files with 27 additions and 10 deletions
|
@ -906,14 +906,23 @@ export class DialogKeywords {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const value = extractEntity(answer);
|
const parseDate = str => {
|
||||||
|
function pad(x){return (((''+x).length==2) ? '' : '0') + x; }
|
||||||
|
var m = str.match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/)
|
||||||
|
, d = (m) ? new Date(m[3], m[2]-1, m[1]) : null
|
||||||
|
, matchesPadded = (d&&(str==[pad(d.getDate()),pad(d.getMonth()+1),d.getFullYear()].join('/')))
|
||||||
|
, matchesNonPadded = (d&&(str==[d.getDate(),d.getMonth()+1,d.getFullYear()].join('/')));
|
||||||
|
return (matchesPadded || matchesNonPadded) ? d : null;
|
||||||
|
}
|
||||||
|
|
||||||
if (value === null || value.length != 1) {
|
let value = parseDate(answer);
|
||||||
|
|
||||||
|
if (value === null) {
|
||||||
await this.talk({ pid, text: 'Por favor, digite uma data no formato 12/12/2020.' });
|
await this.talk({ pid, text: 'Por favor, digite uma data no formato 12/12/2020.' });
|
||||||
return await this.hear({ pid, kind, args });
|
return await this.hear({ pid, kind, args });
|
||||||
}
|
}
|
||||||
|
value = new Date(value);
|
||||||
result = value;
|
result = value.toLocaleString('pt-BR', { day: '2-digit', month: '2-digit', year: 'numeric' });
|
||||||
} else if (kind === 'hour') {
|
} else if (kind === 'hour') {
|
||||||
const extractEntity = (text: string) => {
|
const extractEntity = (text: string) => {
|
||||||
return text.match(/^([0-1]?[0-9]|2[0-4]):([0-5][0-9])(:[0-5][0-9])?$/gi);
|
return text.match(/^([0-1]?[0-9]|2[0-4]):([0-5][0-9])(:[0-5][0-9])?$/gi);
|
||||||
|
|
|
@ -486,6 +486,14 @@ export class SystemKeywords {
|
||||||
|
|
||||||
// TODO: Add a semaphore between FILTER and SET.
|
// TODO: Add a semaphore between FILTER and SET.
|
||||||
|
|
||||||
|
// Processes FILTER option to ensure parallel SET calls.
|
||||||
|
|
||||||
|
const filter = await DialogKeywords.getOption({ pid, name: 'filter' });
|
||||||
|
if (filter) {
|
||||||
|
const row = this.find({ pid, handle: null, args: [filter] });
|
||||||
|
address += row['line'];
|
||||||
|
}
|
||||||
|
|
||||||
// Handles calls for BASIC persistence on sheet files.
|
// Handles calls for BASIC persistence on sheet files.
|
||||||
|
|
||||||
GBLog.info(`BASIC: Defining '${address}' in '${file}' to '${value}' (SET). `);
|
GBLog.info(`BASIC: Defining '${address}' in '${file}' to '${value}' (SET). `);
|
||||||
|
|
|
@ -98,7 +98,7 @@ import { WebAutomationServices } from '../../basic.gblib/services/WebAutomationS
|
||||||
import { createKoaHttpServer } from '../../basic.gblib/index.js';
|
import { createKoaHttpServer } from '../../basic.gblib/index.js';
|
||||||
import { DebuggerService } from '../../basic.gblib/services/DebuggerService.js';
|
import { DebuggerService } from '../../basic.gblib/services/DebuggerService.js';
|
||||||
import { ImageProcessingServices } from '../../basic.gblib/services/ImageProcessingServices.js';
|
import { ImageProcessingServices } from '../../basic.gblib/services/ImageProcessingServices.js';
|
||||||
|
import { ScheduleServices } from '../../basic.gblib/services/ScheduleServices.js';
|
||||||
/**
|
/**
|
||||||
* Minimal service layer for a bot and encapsulation of BOT Framework calls.
|
* Minimal service layer for a bot and encapsulation of BOT Framework calls.
|
||||||
*/
|
*/
|
||||||
|
@ -237,11 +237,11 @@ export class GBMinService {
|
||||||
|
|
||||||
GBLogEx.info(0, 'API RPC HTTP Server started.');
|
GBLogEx.info(0, 'API RPC HTTP Server started.');
|
||||||
|
|
||||||
// // Loads schedules.
|
// Loads schedules.
|
||||||
// GBLog.info(`Preparing SET SCHEDULE dialog calls...`);
|
|
||||||
|
|
||||||
// const service = new ScheduleServices();
|
GBLog.info(`Preparing SET SCHEDULE dialog calls...`);
|
||||||
// await service.scheduleAll();
|
const service = new ScheduleServices();
|
||||||
|
await service.scheduleAll();
|
||||||
|
|
||||||
GBLog.info(`All Bot instances loaded.`);
|
GBLog.info(`All Bot instances loaded.`);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue