whiskeysockets / baileys Goto Github PK
View Code? Open in Web Editor NEWLightweight full-featured typescript/javascript WhatsApp Web API
Home Page: https://whiskeysockets.github.io/Baileys/
License: MIT License
Lightweight full-featured typescript/javascript WhatsApp Web API
Home Page: https://whiskeysockets.github.io/Baileys/
License: MIT License
i m using this code
const keys = { remoteJid: groupMetadata.id, id: mek.id,participant: m.sender,
}
// pass to readMessages function
// can pass multiple keys to read multiple messages as well
await client.readMessages([keys]);
but the the code is not working. It's won't read any message, even in personal chat .
anyone can help?
When trying to create a session using:
const {state, saveCred} = await useHarperDB(botName)
const sock = makeWASocket.default({
logger,
printQRInTerminal: true,
auth: {
creds: state.creds,
keys: makeCacheableSignalKeyStore(state.keys, logger)
},
msgRetryCounterCache,
generateHighQualityLinkPreview: true
})
It gives the QR but when scanned, it raises an error:
[17:03:09.689] INFO (16624): pairing configured successfully, expect to restart the connection...
me: {
"id": "447700XXXXXX:[email protected]"
}
platform: "android"
[17:03:10.043] ERROR (16624): stream errored out
node: {
"tag": "stream:error",
"attrs": {
"code": "515"
}
}
[17:03:10.044] INFO (16624): connection errored
trace: "Error: Stream Errored (restart required)\n at WebSocket.<anonymous> (C:\Users\hey\IdeaProjects\benbecula\node_modules\@whiskeys
ockets\baileys\lib\Socket\socket.js:435:13)\n at WebSocket.emit (node:events:513:28)\n at C:\Users\hey\IdeaProjects\benbecula\node_modul
es\@whiskeysockets\baileys\lib\Socket\socket.js:233:35\n at Object.decodeFrame (C:\Users\hey\IdeaProjects\benbecula\node_modules\@whiskeyso
ckets\baileys\lib\Utils\noise-handler.js:131:17)\n at WebSocket.onMessageRecieved (C:\Users\hey\IdeaProjects\benbecula\node_modules\@whiske
ysockets\baileys\lib\Socket\socket.js:209:15)\n at WebSocket.emit (node:events:513:28)\n at Receiver.receiverOnMessage (C:\Users\hey\Ide
aProjects\benbecula\node_modules\ws\lib\websocket.js:1184:20)\n at Receiver.emit (node:events:513:28)\n at Receiver.dataMessage (C:\Users\
hey\IdeaProjects\benbecula\node_modules\ws\lib\receiver.js:526:14)\n at Receiver.getData (C:\Users\hey\IdeaProjects\benbecula\node_module
s\ws\lib\receiver.js:459:17)\n at Receiver.startLoop (C:\Users\hey\IdeaProjects\benbecula\node_modules\ws\lib\receiver.js:158:22)\n at R
eceiver._write (C:\Users\hey\IdeaProjects\benbecula\node_modules\ws\lib\receiver.js:84:10)\n at writeOrBuffer (node:internal/streams/writab
le:392:12)\n at _write (node:internal/streams/writable:333:10)\n at Writable.write (node:internal/streams/writable:337:10)\n at TLSSock
et.socketOnData (C:\Users\hey\IdeaProjects\benbecula\node_modules\ws\lib\websocket.js:1278:35)\n at TLSSocket.emit (node:events:513:28)\n
at addChunk (node:internal/streams/readable:324:12)\n at readableAddChunk (node:internal/streams/readable:297:9)\n at Readable.push (nod
e:internal/streams/readable:234:10)\n at TLSWrap.onStreamRead (node:internal/stream_base_commons:190:23)\n at TLSWrap.callbackTrampoline (node:internal/async_hooks:130:17)"
[17:03:10.046] INFO (16624): Connection Status:
[17:03:10.047] INFO (16624): Restart Required, Restarting...
modules\ws\lib\receiver.js:84:10)
at writeOrBuffer (node:internal/streams/writable:392:12)
at _write (node:internal/streams/writable:333:10)
at Writable.write (node:internal/streams/writable:337:10)
at TLSSocket.socketOnData (C:\Users\hey\IdeaProjects\benbecula\node_modules\ws\lib\websocket.js:1278:35)
at TLSSocket.emit (node:event s:513:28)
at addChunk (node:internal/streams/readable:324:12)
at readableAddChunk (node:internal/streams/readale:297:9)
at Readable.push (node:internal/streams/readable:234:10)
at TLSWrap.onStreamRead (node:internal/stram_base_commons:190:23)
at TLSWrap.callbackTrampoline (node:internal/async_hooks:130:17)"
PS: The same code was working perfectly fine previous week.
On Restarting, it goes in the loop of sending QR.
Describe the bug
A clear and concise description of what the bug is.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Ao executar apresenta o seguinte erro:
{"level":50,"time":1682517324847,"pid":5378,"hostname":"localhost","err":{"type":"Error","message":"bad-request","stack":"Error: bad-request\n at assertNodeErrorFree (/root/api-whatsapp-ehost/node_modules/@adiwajshing/baileys/lib/WABinary/generic-utils.js:56:15)\n at query (/root/api-whatsapp-ehost/node_modules/@adiwajshing/baileys/lib/Socket/socket.js:128:48)\n at runMicrotasks (<anonymous>)\n at processTicksAndRejections (internal/process/task_queues.js:95:5)\n at async Object.groupAcceptInvite (/root/api-whatsapp-ehost/node_modules/@adiwajshing/baileys/lib/Socket/groups.js:110:29)\n at async WhatsAppInstance.groupAcceptInvite (/root/api-whatsapp-ehost/src/api/class/instance.js:1014:25)\n at async exports.joinGroupViaInviteCode (/root/api-whatsapp-ehost/src/api/controllers/group.controller.js:112:18)","data":400,"isBoom":true,"isServer":true,"output":{"statusCode":500,"payload":{"statusCode":500,"error":"Internal Server Error","message":"An internal server error occurred"},"headers":{}}},"msg":"bad-request"}
Hello,
When I delete a chat on my phone, the chats.delete
event returns an array containing 2 jIds. One of the jIds is not the jId of the deleted chat, which causes a keyed-db
error (Value not found) when I implement the Data Store.
The Discord Link Get Expired Please Update it or Any One Have @adiwajshing Discord username or server link please also update that in README.md
I updated Baileys to the latest version (at this very moment), but now I get the "No Sessions" error
C:\b\node_modules\libsignal\src\session_cipher.js:71
throw new errors.SessionError("No sessions");
is there a bug in the lib when the message contains documentWithCaptionMessage?
Describe the bug
On the import line it gives me an error - Cannot find module '@adiwajshing/baileys' or its corresponding type declarations.
import makeWASocket, {DisconnectReason, makeInMemoryStore, isJidGroup, useMultiFileAuthState} from '@adiwajshing/baileys'
The same line worked fine with the previous repo, adiwajshing/baileys
To Reproduce
Steps to reproduce the behavior:
yarn add github:WhiskeySockets/Baileys
npm run build
(I'm using nest
for that)Expected behavior
It works :)
Environment (please complete the following information):
Additional context
The same code with adiwajshing/baileys
dependency from node_modules
works fine. No changes made.
Describe the bug
Couldn't read/get group message from webhook (incoming message), message was missing in return JSON during group message
To Reproduce
Steps to reproduce the behavior:
Environment (please complete the following information):
Can Anyone Upload This Modules In Npmjs.com
I Tried But Its Giving Error Of tsc and typedoc
Buttons message doesn't appear in current whatsapp from google play
I noticed that there was a merge about event support for labels
But I would like to know if it is possible to add a label to a contact using Baileys
Hello, I'm having this error when trying to send messages to groups.
Failed to decrypt message with any known session... Session error:MessageCounterError: Key used already or never filled MessageCounterError: Key used already or never filled at SessionCipher.doDecryptWhisperMessage (/home/-/-/node_modules/libsignal/src/session_cipher.js:236:19)
I've tried to rescan the session and it follows.
I'm using useMultiFileAuthState('...') as stated in the documentation
would anyone know what could be causing this?
(node:23359) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'fromMe' of undefined
1|index | at generateWAMessageFromContent (/root/xinzuov3.0.2/node_modules/@adiwajshing/baileys/lib/Utils/messages.js:405:40)
1|index | at generateWAMessage (/root/xinzuov3.0.2/node_modules/@adiwajshing/baileys/lib/Utils/messages.js:463:53)
1|index | at runMicrotasks ()
1|index | at processTicksAndRejections (internal/process/task_queues.js:95:5)
1|index | at async Object.Socket.client.generateMessage (/root/xinzuov3.0.2/system/extra.js:59:22)
1|index | (node:23359) UnhandledPromiseRejectionWarning: Unhandled promise rejection.
Could someone help me with some code, explanation or something about how to add multiple participants in my group without getting banned, when i use !addcontacts the command add multiple contacts without banned for example, like 100/200 contacts... I'll be grateful for the help.
It's a Javascript library and without NPM what's the point of this library?
I understand devs work on this in their free time but it literally take 5-6mins to setup everything and make a NPM package.
Describe the bug
A clear and concise description of what the bug is.
Some of the messages I've received from events['messages.upsert'] have Invalid PreKey ID, does anyone have any idea why this is happening and how to fix it?
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Receive the contents of the message according to what we receive on WhatsApp
Environment (please complete the following information):
connectOptions
look like?const sock = makeWASocket({ printQRInTerminal: true, patchMessageBeforeSending: (message) => { const requiresPatch = !!( message.buttonsMessage || message.templateMessage || message.listMessage ); if (requiresPatch) { message = { viewOnceMessage: { message: { messageContextInfo: { deviceListMetadataVersion: 2, deviceListMetadata: {}, }, ...message, }, }, }; } return message; }, auth: state, msgRetryCounterMap, markOnlineOnConnect: false, shouldIgnoreJid: jid => isJidStatusBroadcast(jid), defaultQueryTimeoutMs: undefined });
Additional context
This Problem does not occur in all messages
means there is no solution for now?
Can't sending list on group, that's are supporting on device.
how can I send or create stories in this baileys module. in the example on github they changed the function from id to status@broadcast but my try failed and the code was stopped
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
The messages.reaction event fires only when you set or change a reaction.
Is there any way to tell if the reaction has been removed?
I want to ask this,
Is there a way to retrieve all past WhatsApp messages ?
yarn add github:WhiskeySockets/Baileys
main.js:
const { makeWASocket } = require('@adiwajshing/baileys');
error:
node:internal/modules/cjs/loader:444
throw err;
^
Error: Cannot find module '/home/user/dev/tries/baileys/node_modules/@adiwajshing/baileys/lib/index.js'. Please verify that the package.json has a valid "main" entry
at tryPackage (node:internal/modules/cjs/loader:436:19)
at Module._findPath (node:internal/modules/cjs/loader:678:18)
at Module._resolveFilename (node:internal/modules/cjs/loader:1061:27)
at Module._load (node:internal/modules/cjs/loader:920:27)
at Module.require (node:internal/modules/cjs/loader:1141:19)
at require (node:internal/modules/cjs/helpers:110:18)
at Object.<anonymous> (/home/user/dev/tries/baileys/main.js:1:26)
at Module._compile (node:internal/modules/cjs/loader:1254:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
at Module.load (node:internal/modules/cjs/loader:1117:32) {
code: 'MODULE_NOT_FOUND',
path: '/home/user/dev/tries/baileys/node_modules/@adiwajshing/baileys/package.json',
requestPath: '@adiwajshing/baileys'
}
Node.js v18.16.0
> I forgot to be reply, but there's a server side filter now. So the issue cannot be solved. Btw only buttons, list and template are getting deprecated
thanks @Auties00 for clarifications.
Originally posted by @reski-rukmantiyo in #56 (comment)
I was seeing that when removing the code:
const buttonType = getButtonType(message);
if (buttonType) {
stanza.content.push({
tag: 'biz',
attrs: {},
content: [
{
tag: buttonType,
attrs: getButtonArgs(message),
}
]
});
logger.debug({ jid }, 'adding business node');
}
The buttons are sent again by whatsapp, but they do not appear, only in old versions
Describe the bug
When installing the package locally to update, the error below appears regarding WebSocket. I corrected the error, removing the sendPromise
variable, and calling ws.send
, inside the sendRawMessage
function, so as not to have more errors.
To Reproduce
Steps to reproduce the behavior:
Describe the bug
After a while with the #14 issue, the error has now changed
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The message is sent and the bot doesn't crash.
Environment (please complete the following information):
connectOptions
look like?makeWASocket({
...this.opts?.baileysOpts,
logger: P({ level: "silent" }),
auth: state,
browser: Browsers.appropriate("Desktop"),
getMessage: async (key) => {
const { id } = key;
return tempStore[id!]?.message!;
}
});
Additional context
The error doesn't appear if I send the message on my own chat
HOW TO DELETE MESSAGE BY ADMIN
when tried to get all chats using
var chs = await wa.store.chats;
getting error Cannot read properties of undefined (reading 'chats')
i want to featch all open chats
Describe the bug
When I build my project for development (nodemon --watch src src/server.ts
) works fine, but I build it for production (tsc
), it throws 2 errors from this project:
node_modules/@adiwajshing/baileys/lib/Socket/index.d.ts:2:23 - error TS2688: Cannot find type definition file for 'ws'.
2 /// <reference types="ws" />
~~
node_modules/@adiwajshing/baileys/lib/Socket/index.d.ts:78:16 - error TS7016: Could not find a declaration file for module 'ws'. '/Users/lucas/Projects/Voxuy/Voxuy.WhatsApp.Baileys/node_modules/ws/index.js' implicitly has an 'any' type.
Try `npm i --save-dev @types/ws` if it exists or add a new declaration (.d.ts) file containing `declare module 'ws';`
78 ws: import("ws");
~~~~
Found 2 errors in the same file, starting at: node_modules/@adiwajshing/baileys/lib/Socket/index.d.ts:2
To Reproduce
Steps to reproduce the behavior:
"@adiwajshing/baileys": "https://github.com/WhiskeySockets/Baileys"
tsc
Expected behavior
Build it with no errors
Environment (please complete the following information):
connectOptions
look like? not relevantAdditional context
i've already tried adding the project in different ways, via NPM and github:WhiskeySockets/Baileys
, but they all throw the same issue
Before adding this issue, make sure you do the following to make sure this is not a duplicate:
I am interested in handling incoming voice calls on WhatsApp programmatically.
Receive incoming WhatsApp calls
Answer the call
Receive streaming data and send data back simultaneously in a bidirectional connection
End the call
I can't use the function externalAdReply in extendedTextMessage, How to solve it?
Due to a new whatsapp update, my bot no longer sends messages in groups. Is there anyone else with this problem?
Hello all!
Describe the bug
I'm facing a problem when starting a process, connecting some phone numbers through QR code, everything's working fine, I can send messages, receive upsert events.
But after some time (4-5 hours) the socket stops receiving the upsert events. I can still connect/disconnect, but the message upsert events won't come.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The message events shouldn't stop, or if there's any problem with the socket, there should be an error message.
Environment:
connectOptions
:const browser = Browsers.appropriate('Desktop');
const socket = makeWASocket({
logger: this.logger, // pino logger with level 'error'
syncFullHistory: false,
shouldSyncHistoryMessage: () => false,
auth: { // custom MySQL auth state
creds: state?.creds,
keys: state?.keys,
},
browser: browser
});
Any help would be welcome!
Describe the bug
When trying to change the profile name, it returns the following error:
{
"statusCode": 404,
"error": "Not Found",
"message": "myAppStateKey (\"AAAAALVm\") not present"
}
To Reproduce
Steps to reproduce the behavior:
instance.socket?.updateProfileName("New Name")
Tipo quero usar enquete como botão aí preciso saber como o baileys sabe qual opçao da enquete o usuário votou me ajudem por favor
Is onWhatsApp method not accurate, not like on Adiwajshing?
I have try 1 number to verify with onWhatsApp method using WhiskeySockets always not exists, but when using Adiwajshing is exists.
How? Anyone explain this to me pls!?
How to send Polls is missing there
Will they keep updating the project or is it just to save the files? :)
Describe the bug
To Reproduce
Steps to reproduce the behavior:
Follow the exact guidelines in
https://whiskeysockets.github.io/docs/tutorial-basics/sending-messages#non-media-messages
const vcard =
"BEGIN:VCARD\n" + // metadata of the contact card
"VERSION:3.0\n" +
"FN:Jeff Singh\n" + // full name
"ORG:Ashoka Uni;\n" + // the organization of the contact
"TEL;type=CELL;type=VOICE;waid=911234567890:+91 12345 67890\n" + // WhatsApp ID + phone number
"END:VCARD";
const sentMsg = await sock.sendMessage(id, {
contacts: {
displayName: "Jeff",
contacts: [{ vcard }],
},
});
Expected behavior
The contact should be received, including the name of the contact, which doesn't happen..
What's received is a generic "Contact" contact
And when you open it, the name doesn't show up:
If you replace "FN" with "N" (and add semi-colons), the name appears in the contact.
const vcard =
"BEGIN:VCARD\n" + // metadata of the contact card
"VERSION:3.0\n" +
"N:Jeff;Singh\n" + // full name
"ORG:Ashoka Uni;\n" + // the organization of the contact
"TEL;type=CELL;type=VOICE;waid=911234567890:+91 12345 67890\n" + // WhatsApp ID + phone number
"END:VCARD";
I couldn't "fix" the JSON keyname for the name to be shown on the messagelist
Updating the guide would be enough for (1) but for (2) I suppose whatsapp server made changes..
Thanks!
Just spent 2 hours trying to get the GitHub Actions working. I give up now.
The workflow can't fetch libsignal via ssh because there is no ssh key, if you make a rule to use https over ssh it will not be able to push the docs. Adding a rule doing the reverse doesn't fix it unfortunately. I was wondering why it insists on ssh when the package.json explicitly allows https and found the answer in the yarn.lock. If I remove the yarn.lock and run yarn again it does introduce https however then the action fails with https://github.com/burstfreeze-alt/Baileys/actions/runs/4764988082/jobs/8470216597#step:5:12
I suppose there is something being fetched wrong when using https. We could add an ssh key and add some code to make the action generate the request with the ssh key in mind however I don't think that's the right direction given that in the original repo it wasn't required either. The only exception to that would be that ssh keys aren't required for public repos within the same user but that seems unlikely do me.
Ideas?
Describe the bug
I connected my phone, everything was working, but then after a time in event 'connection.update' i suddenly get
{"connection":"close","lastDisconnect":{"error":{"data":null,"isBoom":true,"isServer":false,"output":{"statusCode":428,"payload":{"statusCode":428,"error":"Precondition Required","message":"Connection Terminated"},"headers":{}}},"date":"2023-05-25T07:45:02.732Z"}}
and messages are no longer sent.
To Reproduce
Steps to reproduce the behavior:
Environment:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.