fix(basic.gblib): New AUTO SAVE keyword.
This commit is contained in:
parent
43f88e83e4
commit
e5de297586
6 changed files with 34 additions and 9 deletions
|
@ -180,7 +180,7 @@
|
|||
"vm2-process": "2.1.1",
|
||||
"walk-promise": "0.2.0",
|
||||
"washyourmouthoutwithsoap": "1.0.2",
|
||||
"whatsapp-web.js": "1.20.0",
|
||||
"whatsapp-web.js": "1.22.1",
|
||||
"winston": "3.8.2",
|
||||
"winston-logs-display": "1.0.0",
|
||||
"ws": "8.12.1",
|
||||
|
|
|
@ -1223,13 +1223,21 @@ export class DialogKeywords {
|
|||
const reply = { type: ActivityTypes.Message, text: caption };
|
||||
|
||||
const imageData = await (await fetch(url)).arrayBuffer();
|
||||
const base64Image = Buffer.from(imageData).toString('base64');
|
||||
const contentType = mime.lookup(url);
|
||||
reply['attachments'] = [];
|
||||
|
||||
// Prepare a cache to be referenced by Bot Framework.
|
||||
|
||||
let buf: any = Buffer.from(imageData);
|
||||
const gbaiName = DialogKeywords.getGBAIPath(min.botId);
|
||||
const localName = Path.join('work', gbaiName, 'cache', `tmp${GBAdminService.getRndReadableIdentifier()}.docx`);
|
||||
Fs.writeFileSync(localName, buf, { encoding: null });
|
||||
url = urlJoin(GBServer.globals.publicAddress, min.botId, 'cache', Path.basename(localName));
|
||||
|
||||
reply['attachments'].push({
|
||||
name: nameOnly,
|
||||
contentType: contentType,
|
||||
contentUrl: `data:${contentType};base64,${base64Image}`
|
||||
contentUrl: url
|
||||
});
|
||||
|
||||
if (channel === 'omnichannel') {
|
||||
|
|
|
@ -1268,7 +1268,7 @@ export class GBMinService {
|
|||
: min.core.getParam(min.instance, 'Start Dialog', null);
|
||||
|
||||
if (
|
||||
startDialog &&
|
||||
startDialog && startDialog!=="" &&
|
||||
!min['conversationWelcomed'][step.context.activity.conversation.id] &&
|
||||
!step.context.activity['group']
|
||||
) {
|
||||
|
@ -1348,6 +1348,10 @@ export class GBMinService {
|
|||
}
|
||||
min.cbMap[userId].promise = results[0];
|
||||
}
|
||||
else{
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -108,7 +108,9 @@ export class AskDialog extends IGBDialog {
|
|||
text = Messages[locale].ask_first_time;
|
||||
}
|
||||
else if (step.options && step.options.isReturning && !step.context.activity.group) {
|
||||
text = Messages[locale].anything_else;
|
||||
const askForMore = min.core.getParam(min.instance, 'Ask For More', null);
|
||||
|
||||
text = askForMore?Messages[locale].anything_else: '';
|
||||
}
|
||||
else if (step.context.activity.group || (step.options && step.options.emptyPrompt)) {
|
||||
text = '';
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
| |
|
||||
\*****************************************************************************/
|
||||
|
||||
import mime from 'mime-types';
|
||||
import urlJoin from 'url-join';
|
||||
import SwaggerClient from 'swagger-client';
|
||||
import Path from 'path';
|
||||
|
@ -49,6 +50,7 @@ import { GBSSR } from '../../core.gbapp/services/GBSSR.js';
|
|||
import pkg from 'whatsapp-web.js';
|
||||
import { DialogKeywords } from '../../basic.gblib/services/DialogKeywords.js';
|
||||
import { ChatServices } from '../../gpt.gblib/services/ChatServices.js';
|
||||
import { GBAdminService } from '../../admin.gbapp/services/GBAdminService.js';
|
||||
const { List, Buttons, Client, MessageMedia } = pkg;
|
||||
|
||||
/**
|
||||
|
@ -315,11 +317,19 @@ export class WhatsappDirectLine extends GBService {
|
|||
|
||||
if (message.hasMedia) {
|
||||
const base64Image = await message.downloadMedia();
|
||||
|
||||
let buf: any = Buffer.from(base64Image.data, "base64");
|
||||
const gbaiName = DialogKeywords.getGBAIPath(this.min.botId);
|
||||
const localName = Path.join('work', gbaiName, 'cache', `tmp${GBAdminService.getRndReadableIdentifier()}.docx`);
|
||||
Fs.writeFileSync(localName, buf, { encoding: null });
|
||||
const url = urlJoin(GBServer.globals.publicAddress, this.min.botId, 'cache', Path.basename(localName));
|
||||
|
||||
attachments = [];
|
||||
attachments.push({
|
||||
name: 'uploaded.png',
|
||||
name: `${new Date().toISOString().replace(/\:/g, '')}.${mime.extension(base64Image.mimetype)}`,
|
||||
noName: true,
|
||||
contentType: base64Image.mimetype,
|
||||
contentUrl: `data:${base64Image.mimetype};base64,${base64Image.data}`
|
||||
contentUrl: url
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -102,8 +102,9 @@ export class GBServer {
|
|||
GBServer.globals.indexSemaphore = new Mutex();
|
||||
|
||||
server.use(bodyParser.json());
|
||||
server.use(bodyParser.urlencoded({ extended: true }));
|
||||
|
||||
server.use(bodyParser.json({limit: '100mb'}));
|
||||
server.use(bodyParser.urlencoded({limit: '100mb', extended: true}));
|
||||
|
||||
// Setups global error handlers.
|
||||
|
||||
process.on('unhandledRejection', (err, p) => {
|
||||
|
|
Loading…
Add table
Reference in a new issue