Answer the question
In order to leave comments, you need to log in
Not possible mailing to users in pytelegrambotapi?
def spam_message(message):
chat_id = message.chat.id
text = message.text
cursor.execute('SELECT count(*) FROM users')
kolvo_strok_tuple = cursor.fetchone()
kolvo_strok = int(kolvo_strok_tuple[0])
cursor.execute('SELECT user_id FROM users')
vse_user = cursor.fetchall()
if message.text != None:
user = 0
for i in range(kolvo_strok):
try:
bot.send_message(vse_user[0][0], f'{text}')
vse_user.pop(0)
user += 1
except telebot.apihelper.ApiException:
pass
Answer the question
In order to leave comments, you need to log in
Throw out kolvo_strok and iterate over vse_user, then pop is not needed and your except will work fine. Well, you don’t need to get into bots, and especially mailing lists, with such knowledge.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question