dilame / instagram-private-api

NodeJS Instagram private API SDK. Written in TypeScript.
MIT License
5.85k stars 1.13k forks source link

IgActionSpamError when send DM #1084

Open serg2801 opened 4 years ago

serg2801 commented 4 years ago

Hi all.

Form

Question

I have this error when try to send DM.

IgActionSpamError: POST /api/v1/direct_v2/threads/broadcast/text/ - 400 Bad Request; feedback_required at Request.handleResponseError (/Users/sergey/RubymineProjects/node/instagenius-instagram-scraper/node_modules/instagram-private-api/dist/core/request.js:98:20) at Request.send (/Users/sergey/RubymineProjects/node/instagenius-instagram-scraper/node_modules/instagram-private-api/dist/core/request.js:52:28) at async DirectThreadRepository.broadcast (/Users/sergey/RubymineProjects/node/instagenius-instagram-scraper/node_modules/instagram-private-api/dist/repositories/direct-thread.repository.js:176:26) at async DirectThreadEntity.broadcast (/Users/sergey/RubymineProjects/node/instagenius-instagram-scraper/node_modules/instagram-private-api/dist/entities/direct-thread.entity.js:180:26) at async DirectThreadEntity.broadcastText (/Users/sergey/RubymineProjects/node/instagenius-instagram-scraper/node_modules/instagram-private-api/dist/entities/direct-thread.entity.js:25:16) at async Device.sendMessage (/Users/sergey/RubymineProjects/node/instagenius-instagram-scraper/services/device.js:115:7) at async SendMessages._sendMessage (/Users/sergey/RubymineProjects/node/instagenius-instagram-scraper/services/instagram/send-messages.js:88:22) at async SendMessages.call (/Users/sergey/RubymineProjects/node/instagenius-instagram-scraper/services/instagram/send-messages.js:79:5) at async /Users/sergey/RubymineProjects/node/instagenius-instagram-scraper/services/jobs.init.js:32:7

Looks like it is API block. I try to send 4 DM per hour. Maybe someone know how to resolve this block?

Here my code maybe I did something wrong?

async sendMessage(user) {
    try {
      await this.ig.entity.directThread([user.id.toString()]).broadcastText(`Hi ${user.username}!  test text`)
      console.log('message was sent to', user.id, user.username  )
    } catch (e) {
      console.error('Device#sendMessage Error', e.message)
      throw e
    }
  }
Nerixyz commented 4 years ago

You're probably doing other things with the account. The error is just showing up once you send a message.

serg2801 commented 4 years ago

I can send one direct message. But when I try send next message to another user I get this error.

alexrmacleod commented 4 years ago

@serg2801 Hi I am going to code a script to send out multiple direct messages per day. Can I see your code? Would same me so much time as I will end up coding the same thing!

serg2801 commented 4 years ago

Hi @alexrmacleod

async sendMessage(user) {
    try {
      await this.ig.entity.directThread([user.id.toString()]).broadcastText(`Hi ${user.username}! I\'m really sorry but i need to spam you!!! Don\'t block me!!! :)`)
      console.log('send message to', user.id, user.username)
    } catch (e) {
      console.error('Device#sendMessage Error', e.name, e.message)
      if (e instanceof IgLoginRequiredError) {
        await this.login()
        return this.sendMessage(user)
      }
      if (e instanceof IgCheckpointError) {
        sentryHelper.sendNotification(e, this.username)
      }
      if (e instanceof IgNotFoundError) return null
      throw e
    }
  }

It is my method for send DM. But my accounts were blocked after I sent few messages. and we took a break from this work for now. if you have progress in this let me know please.