T
T
Ternick2019-07-31 01:41:25
Python
Ternick, 2019-07-31 01:41:25

Why is the bot not sending messages?

When I try to send, this pops up:

telebot.apihelper.ApiException: A request to the Telegram API was unsuccessful. The server returned HTTP 403 Forbidden. Response body:
[b'{"ok":false,"error_code":403,"description":"Forbidden: user is deactivated"}']

And the mailing list doesn't budge :(
Funka:
def broadcast(chat_id):
  while True:
  if getBotUsers() != ["ПУСТО"]:
    for i in getBotUsers():
      bot.send_message(i, text)
      sleep(0.1)
    bot.send_message(chat_id, "Рассылка была завершена !")
  else:
    bot.send_message(chat_id, "Пользователи не были обнаружены !")

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sprait, 2019-07-31
@Ternick

One of the users to whom the mailing is carried out added the bot to the blacklist:
https://core.telegram.org/api/errors#403-forbidden
To prevent the mailing list from dying due to one error, you can wrap it in try/except:

for i in getBotUsers():
    try:
        bot.send_message(i, text)
    except:
        pass

D
Dridger, 2019-07-31
@Dridger

what do you send out?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question