N
N
NaZaR_4iK2022-03-11 21:33:14
Python
NaZaR_4iK, 2022-03-11 21:33:14

How to make tg bot take id from the database and make a mailing list?

According to the code, the bot does not send notifications, but a message arrives that "Successful distribution"
And in the database all users are set as inactive

@dp.message_handler(commands=['sendall'])
async def sendall(message: types.Message):
  if message.chat.type == 'private':
      text = message.text[9:]
      users = db.get_users()
      for row in users:
        try:
          await bot.send_message(row[0], text )
          if int(row[1]) !=1:
            db.set_active(row[0], 1) 	
        except:
          db.set_active(row[0], 0)

      await bot.send_message(message.from_user.id,"Успешная рассылка")

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question