Closed Rcccclaks closed 3 months ago
up, also need help for this
I don't see it as complex, the truth is, you just have to listen to the update of the message
https://github.com/WhiskeySockets/Baileys/issues/38
satriowicaksn
I am going to generate an example
thanks @andresayac I will try it!
I don't see it as complex, the truth is, you just have to listen to the update of the message
38
satriowicaksn
My system does not recognize the update, when I select an option, it activates messages.upsert and not chat-update
I don't see it as complex, the truth is, you just have to listen to the update of the message
38
satriowicaksn
My system does not recognize the update, when I select an option, it activates messages.upsert and not chat-update
hello it's messages.update it's also possible from messages.upsert but it ignores the chats.update, I'm working on an example but before I'm waiting for validation of a pull request,
hello it's messages.update it's also possible from messages.upsert but it ignores the chats.update, I'm working on an example but before I'm waiting for validation of a pull request,
74
When you get it can you let me know?
This is not the final script, it was very improvised to create a bot, but the important thing is that I understand how it works and I try to emit events to read them later. I use a very good library to generate bots called https://github.com/codigoencasa/bot-whatsapp.
https://github.com/andresayac/poll_example_bot_baileys
Poll messages doesn't come from messages.update
event. They're coming from messages.upsert
and format is like that:
{
"key": {
"remoteJid": "905374937766@s.whatsapp.net",
"fromMe": true,
"id": "3AD3XXXXXXXX9BC75F"
},
"messageTimestamp": 1684309796,
"pushName": "Emir Bugra",
"broadcast": false,
"status": 2,
"message": {
"pollUpdateMessage": {
"pollCreationMessageKey": {
"remoteJid": "905374937766@s.whatsapp.net",
"fromMe": true,
"id": "XXXXXXXXXXXXX"
},
"vote": {
"encPayload": "tEjjdA1JcwINxxxxEXQGhO+Bkm7xxxxxxJLlPCbuYImKpJsxxxxxxxrok380EA=",
"encIv": "XEYzxxxxsND92Ru"
},
"senderTimestampMs": "1684309795533"
}
}
}
We must decrypt encPayload
but I don't know how to do that.
Poll messages doesn't come from
messages.update
event. They're coming frommessages.upsert
and format is like that:{ "key": { "remoteJid": "905374937766@s.whatsapp.net", "fromMe": true, "id": "3AD3XXXXXXXX9BC75F" }, "messageTimestamp": 1684309796, "pushName": "Emir Bugra", "broadcast": false, "status": 2, "message": { "pollUpdateMessage": { "pollCreationMessageKey": { "remoteJid": "905374937766@s.whatsapp.net", "fromMe": true, "id": "XXXXXXXXXXXXX" }, "vote": { "encPayload": "tEjjdA1JcwINxxxxEXQGhO+Bkm7xxxxxxJLlPCbuYImKpJsxxxxxxxrok380EA=", "encIv": "XEYzxxxxsND92Ru" }, "senderTimestampMs": "1684309795533" } } }
We must decrypt
encPayload
but I don't know how to do that.
Have you tried the script, it seems that I do not recommend that you document it and do so by leaving several examples above.
I read this it seems not?
https://github.com/WhiskeySockets/Baileys/blob/master/Example/example.ts
Example
git clone https://github.com/andresayac/poll_example_bot_baileys.git
cd poll_example_bot_baileys npm I npm run start Scan qr Send poll this for device Select opción and view terminal
Have you tried the script, it seems that I do not recommend that you document it and do so by leaving several examples above.
I read this it seems not?
https://github.com/WhiskeySockets/Baileys/blob/master/Example/example.ts
Example
git clone https://github.com/andresayac/poll_example_bot_baileys.git
cd poll_example_bot_baileys npm I npm run start Scan qr Send poll this for device Select opción and view terminal
Yep it worked, probably I'm making something wrong in my own project. Thank you so much.
ErrorCaptureStackTrace(err); ^
Error [ERR_MODULE_NOT_FOUND]: Cannot find package '/storage/emulated/0/poll_example_bot_baileys/node_modules/@whiskeysockets/baileys/' imported from /storage/emulated/0/poll_example_bot_baileys/baileys.js
at new NodeError (node:internal/errors:399:5)
at legacyMainResolve (node:internal/modules/esm/resolve:202:9)
at packageResolve (node:internal/modules/esm/resolve:781:14)
at moduleResolve (node:internal/modules/esm/resolve:843:20)
at defaultResolve (node:internal/modules/esm/resolve:1058:11)
at nextResolve (node:internal/modules/esm/hooks:654:28)
at Hooks.resolve (node:internal/modules/esm/hooks:309:30)
at ESMLoader.resolve (node:internal/modules/esm/loader:312:26)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:172:38)
at ModuleWrap.
Node.js v19.9.0
you can clone and try again friend https://github.com/andresayac/bot_baileys
ErrorCaptureStackTrace(err); ^
Error [ERR_MODULE_NOT_FOUND]: Cannot find package '/storage/emulated/0/poll_example_bot_baileys/node_modules/@whiskeysockets/baileys/' imported from /storage/emulated/0/poll_example_bot_baileys/baileys.js at new NodeError (node:internal/errors:399:5) at legacyMainResolve (node:internal/modules/esm/resolve:202:9) at packageResolve (node:internal/modules/esm/resolve:781:14) at moduleResolve (node:internal/modules/esm/resolve:843:20) at defaultResolve (node:internal/modules/esm/resolve:1058:11) at nextResolve (node:internal/modules/esm/hooks:654:28) at Hooks.resolve (node:internal/modules/esm/hooks:309:30) at ESMLoader.resolve (node:internal/modules/esm/loader:312:26) at ESMLoader.getModuleJob (node:internal/modules/esm/loader:172:38) at ModuleWrap. (node:internal/modules/esm/module_job:76:40) { code: 'ERR_MODULE_NOT_FOUND' }
Node.js v19.9.0
você pode clonar e tentar novamente amigo https://github.com/andresayac/bot_baileys
ErrorCaptureStackTrace(err); ^ Erro [ERR_MODULE_NOT_FOUND]: Não é possível encontrar o pacote '/storage/emulated/0/poll_example_bot_baileys/node_modules/@whiskeysockets/baileys/' importado de /storage/emulated/0/poll_example_bot_baileys/baileys.js no novo NodeError (node:internal /errors: 399:5) em legacyMainResolve (node:internal/modules/esm/resolve:202:9) em packageResolve (node:internal/modules/esm/resolve:781:14) em moduleResolve (node:internal/modules/ esm/resolve :843:20) em defaultResolve (node:internal/modules/esm/resolve:1058:11) em nextResolve (node:internal/modules/esm/hooks:654:28) em Hooks.resolve (node:internal /modules/esm/hooks:309:30) em ESMLoader.resolve (node:internal/modules/esm/loader:312:26) em ESMLoader.getModuleJob (node:internal/modules/esm/loader:172:38) em ModuleWrap.(node:internal/modules/esm/module_job:76:40) { código: 'ERR_MODULE_NOT_FOUND' } Node.js v19.9.0
Same error in terminal
you can clone and try again friend https://github.com/andresayac/bot_baileys
ErrorCaptureStackTrace(err); ^ Error [ERR_MODULE_NOT_FOUND]: Cannot find package '/storage/emulated/0/poll_example_bot_baileys/node_modules/@whiskeysockets/baileys/' imported from /storage/emulated/0/poll_example_bot_baileys/baileys.js at new NodeError (node:internal/errors:399:5) at legacyMainResolve (node:internal/modules/esm/resolve:202:9) at packageResolve (node:internal/modules/esm/resolve:781:14) at moduleResolve (node:internal/modules/esm/resolve:843:20) at defaultResolve (node:internal/modules/esm/resolve:1058:11) at nextResolve (node:internal/modules/esm/hooks:654:28) at Hooks.resolve (node:internal/modules/esm/hooks:309:30) at ESMLoader.resolve (node:internal/modules/esm/loader:312:26) at ESMLoader.getModuleJob (node:internal/modules/esm/loader:172:38) at ModuleWrap. (node:internal/modules/esm/module_job:76:40) { code: 'ERR_MODULE_NOT_FOUND' } Node.js v19.9.0
Can you modify this one and send it to me with it working? https://github.com/Rcccclaks/BotBaileys
puedes clonar y volver a intentar amigo https://github.com/andresayac/bot_baileys
ErrorCaptureStackTrace(err); ^ Error [ERR_MODULE_NOT_FOUND]: No se puede encontrar el paquete '/storage/emulated/0/poll_example_bot_baileys/node_modules/@whiskeysockets/baileys/' importado de /storage/emulated/0/poll_example_bot_baileys/baileys.js en el nuevo NodeError (node:internal/errors: 399:5) en legacyMainResolve (node:internal/modules/esm/resolve:202:9) en packageResolve (node:internal/modules/esm/resolve:781:14) en moduleResolve (node:internal/modules/esm/resolve :843:20) en defaultResolve (nodo:interno/módulos/esm/resolve:1058:11) en nextResolve (nodo:interno/módulos/esm/hooks:654:28) en Hooks.resolve (nodo:interno/módulos/ esm/hooks:309:30) en ESMLoader.resolve (nodo:internal/modules/esm/loader:312:26) en ESMLoader.getModuleJob (nodo:internal/modules/esm/loader:172:38) en ModuleWrap. (nodo: interno/módulos/esm/module_job: 76:40) { código: 'ERR_MODULE_NOT_FOUND' } Node.js v19.9.0
¿Puedes modificar este y enviármelo con él funcionando? https://github.com/Rcccclaks/BotBaileys
although there is a lot of work as you have
você pode clonar e voltar a tentar amigo https://github.com/andresayac/bot_baileys
ErrorCaptureStackTrace(err); ^ Erro [ERR_MODULE_NOT_FOUND]: Não foi possível encontrar o pacote '/storage/emulated/0/poll_example_bot_baileys/node_modules/@whiskeysockets/baileys/' importado de /storage/emulated/0/poll_example_bot_baileys/baileys.js no novo NodeError (node: internal/errors: 399:5) en legacyMainResolve (node:internal/modules/esm/resolve:202:9) en packageResolve (node:internal/modules/esm/resolve:781:14) en moduleResolve (node:internal/modules /esm/resolve :843:20) en defaultResolve (nodo:interno/módulos/esm/resolve:1058:11) en nextResolve (nodo:interno/módulos/esm/hooks:654:28) en Hooks.resolve (nodo: interno/módulos/esm/hooks:309:30) em ESMLoader.resolve (nodo:internal/modules/esm/loader:312:26) em ESMLoader.getModuleJob (nodo:internal/modules/esm/loader:172:38) pt ModuleWrap. (nodo: interno/módulos/esm/module_job: 76:40) { código: ' Node.js v19.9.0
Você pode modificar este e enviá-lo com ele funcionando? https://github.com/Rcccclaks/BotBaileys
embora haja muito trabalho como você tem
I was wanting a lot you know
That's why I designed a much more scalable idea as I have it in my repository to play with events and globalize to messages, sometimes it's recommended to use baileys as updates or reactions so I've taken an idea to globalize in an event called messages
git clone https://github.com/andresayac/bot_baileys.git cd bot_baileys npm i npm run start
É por isso que desenvolvi uma ideia muito mais escalável como tenho em meu repositório para brincar com eventos e globalizar para mensagens, às vezes é recomendável usar baileys como atualizações ou reações, então tenho uma ideia para globalizar em um evento chamado mensagens
git clone https://github.com/andresayac/bot_baileys.git cd bot_baileys npm i npm run start
That's why I designed a much more scalable idea as I have it in my repository to play with events and globalize to messages, sometimes it's recommended to use baileys as updates or reactions so I've taken an idea to globalize in an event called messages
git clone https://github.com/andresayac/bot_baileys.git cd bot_baileys npm i npm run start
It's just that this one doesn't work neither in Ubuntu nor in termux
It's just that this one doesn't work neither in Ubuntu nor in termux
I am going to validate on linux
cd bot_baileys npm i npm run start
cd bot_baileys npm i npm run start
![]()
It worked but can you do it on the base I sent you? I'll pay you 10 reais
It worked but can you do it on the base I sent you? I'll pay you 10 reais
believe me it is much easier as you raise it, just scan the qr and everything you get to the message event, and from there you can use the different methods or native oppciones to modify to your liking, the issue is that it depends on the event messages.update and has no logic in the code that you pass me would have to return to condition
Funcionou mas dá pra fazer na base que te mandei? te pago 10 reais
acredite em mim é muito mais fácil conforme você aumenta, basta digitalizar o qr e tudo o que você recebe no evento de mensagem, e a partir daí você pode usar os diferentes métodos ou oppciones nativos para modificar ao seu gosto, a questão é que depende do event message.update e não tem logica no codigo que me passar teria que retornar a condição
Can you pass me some of your means of communication?
Funcionou mas dá pra fazer na base que te mandei? te pago 10 reais
acredite em mim é muito mais fácil conforme você aumenta, basta digitalizar o qr e tudo o que você recebe no evento de mensagem, e a partir daí você pode usar os diferentes métodos ou oppciones nativos para modificar ao seu gosto, a questão é que depende do event message.update e não tem logica no codigo que me passar teria que retornar a condição
Can you pass me some of your means of communication?
discord andresaya#9842
Adding the getMessage function worked for me, the "messages.update" event started to notify on votes
const sock = makeWASocket({
..., // your config
getMessage,
});
Store
const store = makeInMemoryStore({ logger })
function getMessage
async function getMessage(key: WAMessageKey): Promise<WAMessageContent | undefined> {
if(store) {
const msg = await store.loadMessage(key.remoteJid!, key.id!)
return msg?.message || undefined
}
// only if store is present
return proto.Message.fromObject({})
}
The getMessage method is called in processMessage: https://github.com/WhiskeySockets/Baileys/blob/e24947e55ad6e3370de867b258bb33bb9e828c56/src/Utils/process-message.ts#L340
maybe enhacement by @PurpShell https://gist.github.com/PurpShell/44433d21631ff0aefbea57f7b5e31139 < this solution is very difficult to work
how to use getAggregateVotesInPollMessage() on /utils/messages correctly ?
Like, I want to use a poll as a button, so I need to know how Baileys knows which poll option the user voted for, please help me