Answer the question
In order to leave comments, you need to log in
How to send an image to all bot users?
I want to set up a mailing bot. What code to use to send to all users (id collected) the bot with the text to which the photo is attached, and a clickable button below?
Answer the question
In order to leave comments, you need to log in
Hello.
I have not worked with the pyTelegramBotAPI library for a long time, but I did it like this:
def send_image(text, image_path):
keyboard = telebot.types.ReplyKeyboardMarkup()
for button in buttons:
button_name = list(button.keys())[0]
inline_markup = telebot.types.KeyboardButton(text=button_name)
buttons.append(inline_markup)
# встраиваем кнопки в клавиатуре
keyboard.add(*buttons)
image = open(image_path, 'rb')
for user_id in all_user_ids:
sleep(0.3)
bot. send_photo(user_id, photo=image, caption=text, reply_markup=keyboard)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question