Open Ralle opened 4 years ago
For now this is what I do:
client.socketHandler.signaldSocket.on("data", (data) => {
if (typeof data === "string") {
const dataObj = JSON.parse(data);
if (dataObj.type !== "message") {
return;
}
// console.log("JSON", JSON.stringify(dataObj, null, 2));
if (dataObj.data.syncMessage && dataObj.data.syncMessage.sent) {
handleMessage(
dataObj.data.source.number,
dataObj.data.syncMessage.sent.message
);
}
if (dataObj.data.dataMessage) {
handleMessage(dataObj.data.source.number, dataObj.data.dataMessage);
}
}
});
function handleMessage(username, message) {
console.log(username + ":");
console.log("WHEN", new Date(message.timestamp));
if (message.body) {
console.log("MESSAGE", message.body);
}
if (message.attachments) {
for (let i = 0; i < message.attachments.length; i++) {
const a = message.attachments[i];
console.log(
"ATTACHMENT",
i,
a.contentType,
a.storedFilename,
a.customFilename
);
}
}
}
Hello! Apologies for the delayed response. I've been very busy. Thank you for your interest in the project and the feedback. Hopefully, I'll be able to work on this soon. If you find any other quirks, please open more issues and let me know.
Hey! Cool project!
I am trying to make a system that uses your wrapper to listen to a particular conversation and make a web based journal based on the messages. I managed to link my account, subscribe and if I set
SIGNALD_NODE_DEBUG
I can see the messages coming through, but how do I get to them?I realize things are fresh out of the oven. But I figured I might as well contact you in case you know how and/or get motivated to make it work if that code isn't written yet 👍