Reputation: 41
This is my code:
def paid(first, last, uid, contribution, position, number, description, img):
for admin in const.admins:
sleep(10)
bot.send_photo(admin, img)
sleep(1)
bot.send_message(admin, '✅Пользователь {0} {1} ID {2} оплатил заказ "рулетка".'
'\nВзнос: {3} руб.'
'\nТовар {4} № {5} удален из резерва.'
'\n{6}'.format(first,
last,
uid,
contribution,
position,
number,
description))
According to the idea, the code should send to each admin a photo of img, but it sends it only to the first admin, for the others it gives an error:
telebot.apihelper.ApiException: A request to the Telegram API was unsuccessful. The server returned HTTP 400 Bad Request. Response body: [b'{"ok":false,"error_code":400,"description":"Bad Request: file must be non-empty"}'] " 2017-10-05 13:09:18,537 (init.py:292 MainThread) ERROR - TeleBot: "A request to the Telegram API was unsuccessful. The server returned HTTP 400 Bad Request. Response body: [b'{"ok":false,"error_code":400,"description":"Bad Request: file must be non-empty"}']
Moreover, the variable img continues to be <_io.BufferedReader name='img.jpg'>
Upvotes: 3
Views: 469
Reputation: 24
I'm assuming you want the for loop to traverse all the different images? in that case your gonna need to define it more than once
you see what you did here means that all the loops access all of the information given here again and again, with no change. the for loop does not automatically update these variables for you once you've created them using this command below:
def paid(first, last, uid, contribution, position, number, description, img):
Upvotes: 0