H
H
Hentai_Master2021-02-07 19:31:38
Bots
Hentai_Master, 2021-02-07 19:31:38

How to make a telegram bot send photos randomly from an album?

I did it so far to send a specific photo, it remains to figure out how to randomly send a photo:

@bot.message_handler(content_types=['text'])
def send_text(message):
if message.text.lower() == 'hentai':
bot. send_photo(message.chat.id, (
' https://4.bp.blogspot.com/-3swYE12k-pE/VR_5OzkX74I... '))
elif message.text.lower() == 'mom is nearby':
bot .send_photo(message.chat.id, (
' https://pbs.twimg.com/media/EhODS02WoAEsQZI.jpg '))

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alphatom, 2021-02-08
@Hentai_Master

import random

pics_1 = [
    'https://pbs.twimg.com/media/EhODS02WoAEsQZI.jpg',
    'https://pbs.twimg.com/media/EhODS02WoAEsQZI.jpg',
    'https://pbs.twimg.com/media/EhODS02WoAEsQZI.jpg'
]

pics_2 = [
    'https://pbs.twimg.com/media/EhODS02WoAEsQZI.jpg',
    'https://pbs.twimg.com/media/EhODS02WoAEsQZI.jpg',
    'https://pbs.twimg.com/media/EhODS02WoAEsQZI.jpg'
]

@bot.message_handler(content_types=['text'])
def send_text(message):
    pics = None
    text = message.text.lower()

    if text == 'hentai':
        pics = pics_1
    elif text == 'мама рядом':
        pics = pics_2
    // ...
        
    if pics is not None:
        pic = random.choice(pics)
        bot.send_photo(message.chat.id, (pic))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question