Skip to content

Commit

Permalink
feat: Added more options to chatwoot config (close #362)
Browse files Browse the repository at this point in the history
  • Loading branch information
icleitoncosta committed May 31, 2023
1 parent 3c5abb5 commit 577a3cf
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
4 changes: 4 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ export default {
onPollResponse: true,
onRevokedMessage: true,
},
chatwoot: {
sendQrCode: true,
sendStatus: true,
},
archive: {
enable: false,
waitTime: 10,
Expand Down
32 changes: 18 additions & 14 deletions src/util/chatWootClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,25 +55,29 @@ export default class chatWootClient {
//assina o evento do qrcode
eventEmitter.on(`qrcode-${session}`, (qrCode, urlCode, client) => {
setTimeout(async () => {
this.sendMessage(client, {
sender: this.sender,
chatId: this.mobile_number + '@c.us',
type: 'image',
timestamp: 'qrcode',
mimetype: 'image/png',
caption: 'leia o qrCode',
qrCode: qrCode.replace('data:image/png;base64,', ''),
});
if (config?.chatwoot?.sendQrCode !== false) {
this.sendMessage(client, {
sender: this.sender,
chatId: this.mobile_number + '@c.us',
type: 'image',
timestamp: 'qrcode',
mimetype: 'image/png',
caption: 'leia o qrCode',
qrCode: qrCode.replace('data:image/png;base64,', ''),
});
}
}, 1000);
});

//assiona o evento do status
eventEmitter.on(`status-${session}`, (client, status) => {
this.sendMessage(client, {
sender: this.sender,
chatId: this.mobile_number + '@c.us',
body: `wppconnect status: ${status} `,
});
if (config?.chatwoot?.sendStatus !== false) {
this.sendMessage(client, {
sender: this.sender,
chatId: this.mobile_number + '@c.us',
body: `wppconnect status: ${status} `,
});
}
});

//assina o evento de mensagem
Expand Down

0 comments on commit 577a3cf

Please sign in to comment.