new(basic.gblib): SEND FILE pdf as temporary images.
This commit is contained in:
parent
007493628d
commit
975d4961a4
7 changed files with 134 additions and 32 deletions
52
.wwebjs_cache/2.3000.1017045687.html
Normal file
52
.wwebjs_cache/2.3000.1017045687.html
Normal file
File diff suppressed because one or more lines are too long
52
.wwebjs_cache/2.3000.1017050905.html
Normal file
52
.wwebjs_cache/2.3000.1017050905.html
Normal file
File diff suppressed because one or more lines are too long
|
@ -233,7 +233,7 @@
|
||||||
"washyourmouthoutwithsoap": "1.0.2",
|
"washyourmouthoutwithsoap": "1.0.2",
|
||||||
"webdav-server": "2.6.2",
|
"webdav-server": "2.6.2",
|
||||||
"whatsapp-cloud-api": "0.3.1",
|
"whatsapp-cloud-api": "0.3.1",
|
||||||
"whatsapp-web.js": "https://github.com/Julzk/whatsapp-web.js/tarball/jkr_hotfix_7",
|
"whatsapp-web.js": "1.26.1-alpha.1",
|
||||||
"winston": "3.14.2",
|
"winston": "3.14.2",
|
||||||
"ws": "8.18.0",
|
"ws": "8.18.0",
|
||||||
"yaml": "2.5.0",
|
"yaml": "2.5.0",
|
||||||
|
|
|
@ -1429,7 +1429,7 @@ export class DialogKeywords {
|
||||||
);
|
);
|
||||||
GBLog.verbose(`Translated text(playMarkdown): ${text}.`);
|
GBLog.verbose(`Translated text(playMarkdown): ${text}.`);
|
||||||
|
|
||||||
if (step) {
|
if (!isNaN(user.userSystemId)){
|
||||||
await min.conversationalService.sendText(min, step, text, user);
|
await min.conversationalService.sendText(min, step, text, user);
|
||||||
} else {
|
} else {
|
||||||
await min.conversationalService['sendOnConversation'](min, user, text);
|
await min.conversationalService['sendOnConversation'](min, user, text);
|
||||||
|
|
|
@ -1253,15 +1253,12 @@ export class GBConversationalService {
|
||||||
analytics.createMessage(min.instance.instanceId, conversation, null, text);
|
analytics.createMessage(min.instance.instanceId, conversation, null, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isNaN(user.userSystemId)){
|
||||||
try{
|
|
||||||
// TODO: Remove MS BOT Framework and put GBNative.
|
|
||||||
|
|
||||||
await step.context.sendActivity(text);
|
|
||||||
|
|
||||||
} catch {
|
await min.whatsAppDirectLine.sendToDevice(user.userSystemId, text);
|
||||||
await min.whatsAppDirectLine.sendToDevice(user.userSystemId,
|
}
|
||||||
text);
|
else{
|
||||||
|
await step.context.sendActivity(text);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1329,20 +1329,21 @@ export class GBMinService {
|
||||||
const localFileName = path.join(localFolder, packagePath, 'cache', attachment.name);
|
const localFileName = path.join(localFolder, packagePath, 'cache', attachment.name);
|
||||||
|
|
||||||
let buffer;
|
let buffer;
|
||||||
// if (url.startsWith('data:')) {
|
|
||||||
// const base64Data = url.split(';base64,')[1];
|
|
||||||
// buffer = Buffer.from(base64Data, 'base64');
|
|
||||||
// } else {
|
|
||||||
// const options = {
|
|
||||||
// method: 'GET',
|
|
||||||
// encoding: 'binary'
|
|
||||||
// };
|
|
||||||
// const res = await fetch(url, options);
|
|
||||||
// buffer = arrayBufferToBuffer(await res.arrayBuffer());
|
|
||||||
// }
|
|
||||||
//write
|
|
||||||
buffer = await fs.readFile(localFileName);
|
|
||||||
|
|
||||||
|
if (url.startsWith('data:')) {
|
||||||
|
const base64Data = url.split(';base64,')[1];
|
||||||
|
buffer = Buffer.from(base64Data, 'base64');
|
||||||
|
} else {
|
||||||
|
const options = {
|
||||||
|
method: 'GET',
|
||||||
|
encoding: 'binary'
|
||||||
|
};
|
||||||
|
const res = await fetch(url, options);
|
||||||
|
buffer = arrayBufferToBuffer(await res.arrayBuffer());
|
||||||
|
}
|
||||||
|
|
||||||
|
await fs.writeFile(localFileName, buffer);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: attachment.name,
|
name: attachment.name,
|
||||||
filename: localFileName,
|
filename: localFileName,
|
||||||
|
|
|
@ -159,10 +159,10 @@ export class WhatsappDirectLine extends GBService {
|
||||||
const createClient = async () => {
|
const createClient = async () => {
|
||||||
const client = (this.customClient = new Client({
|
const client = (this.customClient = new Client({
|
||||||
puppeteer: await GBSSR.preparePuppeteer(localName),
|
puppeteer: await GBSSR.preparePuppeteer(localName),
|
||||||
webVersionCache: {
|
// webVersionCache: {
|
||||||
type: 'remote',
|
// type: 'remote',
|
||||||
remotePath: `https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/${webVersion}.html`
|
// remotePath: `https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/${webVersion}.html`
|
||||||
}
|
// }
|
||||||
}));
|
}));
|
||||||
client.on(
|
client.on(
|
||||||
'message',
|
'message',
|
||||||
|
@ -226,7 +226,7 @@ export class WhatsappDirectLine extends GBService {
|
||||||
if (chat.isGroup) {
|
if (chat.isGroup) {
|
||||||
// await chat.clearMessages();
|
// await chat.clearMessages();
|
||||||
} else if (!chat.pinned) {
|
} else if (!chat.pinned) {
|
||||||
await chat.delete();
|
//await chat.delete();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -744,7 +744,7 @@ export class WhatsappDirectLine extends GBService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.customClient.sendMessage(to, attachment, { caption: caption });
|
await this.customClient.sendMessage(to, attachment, { caption: caption , viewOnce});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -923,7 +923,7 @@ export class WhatsappDirectLine extends GBService {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async sendToDevice(to: any, msg: string, conversationId) {
|
public async sendToDevice(to: any, msg: string, conversationId, viewOnce= false) {
|
||||||
try {
|
try {
|
||||||
const cmd = '/audio ';
|
const cmd = '/audio ';
|
||||||
let url;
|
let url;
|
||||||
|
@ -984,7 +984,7 @@ export class WhatsappDirectLine extends GBService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((await this.customClient.getState()) === WAState.CONNECTED) {
|
if ((await this.customClient.getState()) === WAState.CONNECTED) {
|
||||||
await this.customClient.sendMessage(to, msg);
|
await this.customClient.sendMessage(to, msg, { isViewOnce: isViewOnce });
|
||||||
} else {
|
} else {
|
||||||
GBLogEx.info(this.min, `WhatsApp OFFLINE ${to}: ${msg}`);
|
GBLogEx.info(this.min, `WhatsApp OFFLINE ${to}: ${msg}`);
|
||||||
}
|
}
|
||||||
|
@ -1013,7 +1013,7 @@ export class WhatsappDirectLine extends GBService {
|
||||||
|
|
||||||
private async WhatsAppCallback(req, res, botId = null) {
|
private async WhatsAppCallback(req, res, botId = null) {
|
||||||
try {
|
try {
|
||||||
if (!req.body && req.type !== 'ptt') {
|
if (!req.body && req.type !== 'ptt' && !req.hasMedia) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue