Answer the question
In order to leave comments, you need to log in
A simple telegram bot?
Good morning. Help understand and implement the bot. Let's divide the question into two parts.
the bot sends pictures, the pictures are divided into groups, cats and dogs. The client chooses what he will receive. Through what methods it is better to implement buttons. As I understand it, 1 script receives data from the client and saves it. how the bot determines which pictures it sends to whom and does not duplicate sending to one client. It is desirable that all this functionality be password-protected on the client.
Can you describe in short or not in short, how can this be implemented?
Answer the question
In order to leave comments, you need to log in
1 - the bot sends a request to select image content
@bot.message_handler(commands=['start']
def question(message):
markup = types.ReplyKeyboardMarkup()
buttondogs = types.KeyboardButton('dogs')
buttoncats = types.KeyboardButton('cats')
markup.add(buttondogs, buttoncats)
bot.reply_to(message, "Animals", reply_markup=markup)
@bot.message_handler(func=lambda message: message in ['dogs', 'cats']
def photo_animals(message):
if message.text == 'dogs':
bot.send_photo(message.chat.id, dog_photo_file_id, reply_to_message_id=message.message_id)
if message.text == 'cats'
bot.send_photo(message.chat.id, cat_photo_file_id, reply_to_message_id=message.message_id)
@bot.message_handler(content_types=['photo'])
def photo_field_id(message):
print(message.photo[0].file_id)
Take a look at the Python Telegram Bot .
There are examples, you can peep the implementation of the simplest bots.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question