wtfaremyinitials / osa-imessage

Send and receive iMessages with nodejs
MIT License
324 stars 54 forks source link

Listening for messages only emits messages sent by me #17

Closed briangonzalez closed 6 years ago

briangonzalez commented 6 years ago

Here's the code I am using. I only see messages from myself.

import imessage from 'osa-imessage'

imessage.listen().on('message', (msg) => {
  console.log(`'${msg.text}' from ${msg.handle}`)
})
wtfaremyinitials commented 6 years ago

What version of macOS are you using?

briangonzalez commented 6 years ago

10.12.6

briangonzalez commented 6 years ago

Looks like the issue is a documentation one. This part should be:

imessage.listen().on('message', (msg) => {
    console.log(`'${msg.text}' from ${msg.handle}`)
})

should be:

imessage.listen().on('message', (msg) => {
    if (!msg.fromMe) console.log(`'${msg.text}' from ${msg.handle}`)
})
briangonzalez commented 6 years ago

This also matches examples/echo.js