B
B
Bergis2021-03-24 23:43:00
Python
Bergis, 2021-03-24 23:43:00

How to fix a Telegram bot stop?

I have a problem - the bot, when waiting for a message input from one user, does not respond to others.

def mathmatic(message):

            # Словарь
            answer = {}

            # Список с серверами
            onlyServer = [base[j][0] for j in range(len(base))]


            for serv in onlyServer:
                answer[serv] = 0


            for i in diction.keys():
                n = inputBot(message, f'Введите кол-во {i} данного предмета, если он отсутсвует у вас, то введите ноль ' )


                if n.isdigit():

                    item = diction[i]
                    for el in item:
                        server = el[0]
                        priceOnOneServ = float( el[1] )
                        answer[server] = answer[server] + (priceOnOneServ * int(n) )


            answer2 = [ [k,v] for k, v in answer.items()]
            bubbleSort(answer2)
            return answer2

How can I make the bot continue to work without waiting for a message input from only one user?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
alekssamos, 2021-03-24
@alekssamos

https://surik00.gitbooks.io/aiogram-lessons/conten...
https://groosha.gitbook.io/telegram-bot-lessons/ch...
Or something like this:

userdata = {} # создали словарь
    # где-нибудь спрашиваем у человек имя
    userdata[message.user.id] = message.text
    # делаем остальные шаги,
    # читаем через userdata[message.user.id] и удаляем
    del userdata[message.user.id]

M
mandico21, 2021-03-25
@mandico21

Use the aiogram library

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question