D
D
duduychvbk992021-10-06 02:11:33
Python
duduychvbk99, 2021-10-06 02:11:33

The bot is not responding. What to do?

if message.text == " Открыть ящик":
                        bot.send_message(message.chat.id, "<b>Открывается...</b>", parse_mode="html", reply_markup=deleted)
                        time.sleep(2)
                        ListOfPrize = 'nothing', 'whybaby', 'holdik', 'fooflik', 'nver4ikk'
                        prize = random.choices(ListOfPrize, weights=(100, 40, 40, 40, 1))
                        print(prize)
                        if prize == "nothing":
                            bot.send_message(message.chat.id, 'Ничего')
                        if prize == "whybaby":
                            bot.send_message(message.chat.id, 'Вайбейби')
                        if prize == "holdik":
                            bot.send_message(message.chat.id, 'Холди')
                        if prize == "nver4ikk":
                            bot.send_message(message.chat.id, 'Нверчи')


The bot just doesn't respond. I use telebot and random.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2021-10-06
@duduychvbk99

You even output the contents to the console prize.
The method random.choicesreturns a list , not a single element (which choice s doesn't ).
So that

prize = random.choices(ListOfPrize, weights=(100, 40, 40, 40, 1))[0]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question