N
N
Nazar Ivakhiv2021-03-27 01:27:53
Python
Nazar Ivakhiv, 2021-03-27 01:27:53

Does not send a return form, what should I do?

Guys, the code is correct, it doesn’t make errors, but it doesn’t send the reverse form, what should I do? It doesn’t show at the end what I wrote to him ..

def process_deliveryEnd_step(message):
    try:
        chat_id = message.chat.id
        user = user_dict[chat_id]
        user.deliveryEnd = message.text
        
        msg = bot.send_message(chat_id, "✔Ваше замовлення успішно оформлено!\n\nЗ вами зв'яжеться кур'єр!\nОрієнтовний час доставки до 30 хвилин.")

        # ваша замовлення
        bot.send_message(chat_id, getRegData(user, 'Ваше замовлення:', message.from_user.first_name), parse_mode="Markdown")
        # отправить в группу
        bot.send_message(token, getRegData(user, 'Замовлення від', bot.get_me().username), parse_mode="Markdown")

    except Exception as e:
        bot.reply_to(message, 'ooops!!')

def getRegData(user, title, name):
    t = Template("$title *$name* \nНаселенний пункт: *$userCity*\n Прізвище та ім'я: *$fullname*\n☎️Телефон: *$phone*\n Назва вулиці: *$homeStreet*\n Номер будинку або під'їзду: *$homeNumber*\n Дата: *$deliveryDate*\n Ваше замовлення: *$deliveryAnd*\n Доповнення щодо замовлення: *$deliveryEnd*")

    return t.substitute({
        'title': title,
        'name': name,
        'userCity': user.city,
        'fullname': user.fullname,
        'phone': user.phone,
        'homeStreet': user.homeStreet,
        'homeNumber': user.homeNumber,
        'deliveryDate': user.deliveryDate,
        'deliveryAnd': user.deliveryAnd,
        'deliveryEnd': user.deliveryEnd,
    })

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
shurshur, 2021-03-27
@shurshur

Who told you that the code is correct? In my opinion, the code is not fucking correct, not to mention that it is not clear what it should do at all.
Who calls these two functions and how. Presumably, process_deliveryEnd_step is called as a message handler? And where is this handler registered? Usually this is done using the message_handler decorator, but here I don’t see anything like that. That is, either you did not bring all the code, or this code really will not do anything.
update : in the end it turned out that an Exception was happening due to the lack of a Template import. And it would be nice if the script showed an error, but no, it wrote to the user that everything is fine.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question