mirror of
https://github.com/cheveguerra/bot-whatsapp.git
synced 2026-04-20 20:49:15 +00:00
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@bot-whatsapp/bot",
|
"name": "@bot-whatsapp/bot",
|
||||||
"version": "0.0.47-alpha.0",
|
"version": "0.0.48-alpha.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "./lib/bundle.bot.cjs",
|
"main": "./lib/bundle.bot.cjs",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@bot-whatsapp/cli",
|
"name": "@bot-whatsapp/cli",
|
||||||
"version": "0.0.54-alpha.0",
|
"version": "0.0.55-alpha.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "create-bot-whatsapp",
|
"name": "create-bot-whatsapp",
|
||||||
"version": "0.0.65-alpha.0",
|
"version": "0.0.66-alpha.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "./lib/bundle.create-bot-whatsapp.cjs",
|
"main": "./lib/bundle.create-bot-whatsapp.cjs",
|
||||||
"files": [
|
"files": [
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@bot-whatsapp/database",
|
"name": "@bot-whatsapp/database",
|
||||||
"version": "0.0.46-alpha.0",
|
"version": "0.0.47-alpha.0",
|
||||||
"description": "Esto es el conector a mysql, pg, mongo",
|
"description": "Esto es el conector a mysql, pg, mongo",
|
||||||
"main": "./lib/mock/index.cjs",
|
"main": "./lib/mock/index.cjs",
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@bot-whatsapp/portal",
|
"name": "@bot-whatsapp/portal",
|
||||||
"version": "0.0.4-alpha.0",
|
"version": "0.0.5-alpha.0",
|
||||||
"description": "Portal WEB para escanear QR",
|
"description": "Portal WEB para escanear QR",
|
||||||
"main": "./lib/portal.http.cjs",
|
"main": "./lib/portal.http.cjs",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ const { bgYellow, cyan } = require('kleur')
|
|||||||
const polka = require('polka')
|
const polka = require('polka')
|
||||||
|
|
||||||
const HTTP_PORT = process.env.PORT || 3000
|
const HTTP_PORT = process.env.PORT || 3000
|
||||||
const QR_FILE = process.env.QR_FILE ?? 'qr.png'
|
const QR_FILE = process.env.QR_FILE ?? 'bot'
|
||||||
const PUBLIC_URL =
|
const PUBLIC_URL =
|
||||||
process.env.PUBLIC_URL ??
|
process.env.PUBLIC_URL ??
|
||||||
process.env.RAILWAY_STATIC_URL ??
|
process.env.RAILWAY_STATIC_URL ??
|
||||||
@@ -23,18 +23,18 @@ const start = (args) => {
|
|||||||
const injectArgs = {
|
const injectArgs = {
|
||||||
port: HTTP_PORT,
|
port: HTTP_PORT,
|
||||||
publicSite: PUBLIC_URL,
|
publicSite: PUBLIC_URL,
|
||||||
qrFile: QR_FILE,
|
name: QR_FILE,
|
||||||
...args,
|
...args,
|
||||||
}
|
}
|
||||||
const { port, publicSite, qrFile } = injectArgs
|
const { port, publicSite, name } = injectArgs
|
||||||
|
|
||||||
polka()
|
polka()
|
||||||
.use(serve)
|
.use(serve)
|
||||||
.get(qrFile, (_, res) => {
|
.get('qr.png', (_, res) => {
|
||||||
const qrSource = [
|
const qrSource = [
|
||||||
join(process.cwd(), qrFile),
|
join(process.cwd(), `${name}.png`),
|
||||||
join(__dirname, '..', qrFile),
|
join(__dirname, '..', `${name}.png`),
|
||||||
join(__dirname, qrFile),
|
join(__dirname, `${name}.png`),
|
||||||
].find((i) => existsSync(i))
|
].find((i) => existsSync(i))
|
||||||
|
|
||||||
const qrMark = [
|
const qrMark = [
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import {
|
|||||||
useStore,
|
useStore,
|
||||||
useStylesScoped$,
|
useStylesScoped$,
|
||||||
} from '@builder.io/qwik'
|
} from '@builder.io/qwik'
|
||||||
import { useLocation } from '@builder.io/qwik-city'
|
|
||||||
import style from './qr.css?inline'
|
import style from './qr.css?inline'
|
||||||
|
|
||||||
export const QR = component$(() => {
|
export const QR = component$(() => {
|
||||||
@@ -19,15 +18,12 @@ export const QR = component$(() => {
|
|||||||
}, 800)
|
}, 800)
|
||||||
})
|
})
|
||||||
|
|
||||||
const location = useLocation()
|
|
||||||
const qrImage = location.query?.qr ?? 'qr.png'
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<img
|
<img
|
||||||
width={350}
|
width={350}
|
||||||
height={350}
|
height={350}
|
||||||
src={qrImage + '?time=' + state.count}
|
src={'qr.png?time=' + state.count}
|
||||||
alt="QR"
|
alt="QR"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@bot-whatsapp/provider",
|
"name": "@bot-whatsapp/provider",
|
||||||
"version": "0.0.52-alpha.0",
|
"version": "0.0.53-alpha.0",
|
||||||
"description": "Esto es el conector a Twilio, Meta, etc...",
|
"description": "Esto es el conector a Twilio, Meta, etc...",
|
||||||
"main": "./lib/mock/index.cjs",
|
"main": "./lib/mock/index.cjs",
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
|
|||||||
@@ -24,16 +24,13 @@ const logger = new Console({
|
|||||||
stdout: createWriteStream(`${process.cwd()}/baileys.log`),
|
stdout: createWriteStream(`${process.cwd()}/baileys.log`),
|
||||||
})
|
})
|
||||||
|
|
||||||
const NAME_DIR_SESSION = `sessions`
|
|
||||||
const PATH_BASE = join(process.cwd(), NAME_DIR_SESSION)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ⚙️ BaileysProvider: Es una clase tipo adaptor
|
* ⚙️ BaileysProvider: Es una clase tipo adaptor
|
||||||
* que extiende clases de ProviderClass (la cual es como interfaz para sber que funciones rqueridas)
|
* que extiende clases de ProviderClass (la cual es como interfaz para sber que funciones rqueridas)
|
||||||
* https://github.com/adiwajshing/Baileys
|
* https://github.com/adiwajshing/Baileys
|
||||||
*/
|
*/
|
||||||
class BaileysProvider extends ProviderClass {
|
class BaileysProvider extends ProviderClass {
|
||||||
globalVendorArgs = { qrFile: 'qr.png' }
|
globalVendorArgs = { name: `bot` }
|
||||||
vendor
|
vendor
|
||||||
saveCredsGlobal = null
|
saveCredsGlobal = null
|
||||||
constructor(args) {
|
constructor(args) {
|
||||||
@@ -46,6 +43,7 @@ class BaileysProvider extends ProviderClass {
|
|||||||
* Iniciar todo Bailey
|
* Iniciar todo Bailey
|
||||||
*/
|
*/
|
||||||
initBailey = async () => {
|
initBailey = async () => {
|
||||||
|
const NAME_DIR_SESSION = `${this.globalVendorArgs.name}_sessions`
|
||||||
const { state, saveCreds } = await useMultiFileAuthState(
|
const { state, saveCreds } = await useMultiFileAuthState(
|
||||||
NAME_DIR_SESSION
|
NAME_DIR_SESSION
|
||||||
)
|
)
|
||||||
@@ -72,6 +70,7 @@ class BaileysProvider extends ProviderClass {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (statusCode === DisconnectReason.loggedOut) {
|
if (statusCode === DisconnectReason.loggedOut) {
|
||||||
|
const PATH_BASE = join(process.cwd(), NAME_DIR_SESSION)
|
||||||
rimraf(PATH_BASE, (err) => {
|
rimraf(PATH_BASE, (err) => {
|
||||||
if (err) return
|
if (err) return
|
||||||
})
|
})
|
||||||
@@ -95,7 +94,10 @@ class BaileysProvider extends ProviderClass {
|
|||||||
`Necesitas ayuda: https://link.codigoencasa.com/DISCORD`,
|
`Necesitas ayuda: https://link.codigoencasa.com/DISCORD`,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
await baileyGenerateImage(qr, this.globalVendorArgs.qrFile)
|
await baileyGenerateImage(
|
||||||
|
qr,
|
||||||
|
`${this.globalVendorArgs.name}.png`
|
||||||
|
)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ const logger = new Console({
|
|||||||
* https://github.com/orkestral/venom
|
* https://github.com/orkestral/venom
|
||||||
*/
|
*/
|
||||||
class VenomProvider extends ProviderClass {
|
class VenomProvider extends ProviderClass {
|
||||||
globalVendorArgs = { qrFile: 'qr.png' }
|
globalVendorArgs = { name: `bot` }
|
||||||
vendor
|
vendor
|
||||||
constructor(args) {
|
constructor(args) {
|
||||||
super()
|
super()
|
||||||
@@ -32,10 +32,11 @@ class VenomProvider extends ProviderClass {
|
|||||||
* Iniciamos el Proveedor Venom
|
* Iniciamos el Proveedor Venom
|
||||||
*/
|
*/
|
||||||
init = async () => {
|
init = async () => {
|
||||||
|
const NAME_DIR_SESSION = `${this.globalVendorArgs.name}_sessions`
|
||||||
try {
|
try {
|
||||||
const client = await venom.create(
|
const client = await venom.create(
|
||||||
{
|
{
|
||||||
session: 'session-base',
|
session: NAME_DIR_SESSION,
|
||||||
multidevice: true,
|
multidevice: true,
|
||||||
},
|
},
|
||||||
(base) => this.generateQr(base),
|
(base) => this.generateQr(base),
|
||||||
@@ -68,7 +69,7 @@ class VenomProvider extends ProviderClass {
|
|||||||
`Necesitas ayuda: https://link.codigoencasa.com/DISCORD`,
|
`Necesitas ayuda: https://link.codigoencasa.com/DISCORD`,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
await venomGenerateImage(qr)
|
await venomGenerateImage(qr, `${this.globalVendorArgs.name}.png`)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -19,13 +19,15 @@ const logger = new Console({
|
|||||||
* https://github.com/pedroslopez/whatsapp-web.js
|
* https://github.com/pedroslopez/whatsapp-web.js
|
||||||
*/
|
*/
|
||||||
class WebWhatsappProvider extends ProviderClass {
|
class WebWhatsappProvider extends ProviderClass {
|
||||||
globalVendorArgs = { qrFile: 'qr.png' }
|
globalVendorArgs = { name: `bot` }
|
||||||
vendor
|
vendor
|
||||||
constructor(args) {
|
constructor(args) {
|
||||||
super()
|
super()
|
||||||
this.globalVendorArgs = { ...this.globalVendorArgs, ...args }
|
this.globalVendorArgs = { ...this.globalVendorArgs, ...args }
|
||||||
this.vendor = new Client({
|
this.vendor = new Client({
|
||||||
authStrategy: new LocalAuth(),
|
authStrategy: new LocalAuth({
|
||||||
|
clientId: `${this.globalVendorArgs.name}_sessions`,
|
||||||
|
}),
|
||||||
puppeteer: {
|
puppeteer: {
|
||||||
headless: true,
|
headless: true,
|
||||||
args: [
|
args: [
|
||||||
@@ -75,7 +77,7 @@ class WebWhatsappProvider extends ProviderClass {
|
|||||||
`Necesitas ayuda: https://link.codigoencasa.com/DISCORD`,
|
`Necesitas ayuda: https://link.codigoencasa.com/DISCORD`,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
await wwebGenerateImage(qr)
|
await wwebGenerateImage(qr, `${this.globalVendorArgs.name}.png`)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user