ohld / igbot

🐙 Free scripts, bots and Python API wrapper. Get free followers with our auto like, auto follow and other scripts!
https://hikerapi.com/p/N2P6iqiM
Apache License 2.0
4.71k stars 1.47k forks source link

Unread Direct inbox threads? #1167

Closed scretr closed 4 years ago

scretr commented 4 years ago

Code:

#function to get custom reply and automatically send it to all unread message threads

from instabot import Bot
import time as t

customReply = input("enter your custom response:\n\n")

bot = Bot(message_delay = 0, max_messages_per_day = 99999)
bot.login()

while True:
    threads = bot.get_pending_thread_requests()
    bot.send_messages(customReply,threads)
    t.sleep(10)

Runs fine but after login completed returns this every 10 seconds:

"INFO - There isn't any pending thread request. INFO - User must be at least one."

I'm trying to write a script to automatically reply to any unread Direct messages with a custom message of my choice. I don't understand why bot.get_pending_thread_requests() isn't returning the right threads. I've tested this with and without unread messages in the inbox and I've still had the same response.

scretr commented 4 years ago

solved it, get_pending_thread_requests() gets pending message requests, not pending messages. my new code:

bot.api.get_inbox_v2()
inbox = bot.last_json
threads = inbox["inbox"]["threads"]
for thread in threads:
   if thread["read_state"] == 1:
      # do something
   else:
      # do something else