M
M
Matvey2021-11-22 15:36:16
Python
Matvey, 2021-11-22 15:36:16

How to execute telegram bot function?

I am making a telegram bot (like a quiz)
pyTelegramBotAPI library
And there is a message parameter
I want to display the function randomly
From, for example, 3 functions: img_1(message), img_2(message), img_3(message)
The message parameter should be, since it is responsible for sending a message
And when the button is clicked, one of the functions should be executed (randomly)
Inside the functions of the image with captions
How to implement it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AlexSeley, 2021-12-08
@mlt_melt

for m in range(1,4)
if m = 1:
bot.send_photo(message.chat.id, "Path to photo_1")
if m = 2:
bot.send_photo(message.chat.id, "Path to photo_2" )
else:
bot.send_photo(message.chat.id, "Path to photo_3")

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question