Esempio n. 1
0
async def showInPeriod(message: types.Message):
    data = message.text[8:].split(' ') # /period 2020-10-02 2020-11-14
    if len(data) != 2:
        await message.answer("Incorrect input for /period command, use /help")
    else:
        try:
            response = Storage.GetByPeriod(message.from_user.id, data[0], data[1])
            parsedData = ""
            for text in response:
                parsedData += "Subject: " + str(text.name) + "\n(ID: " + str(text.ID) + ") task: " + str(text.task) + "\nadded on date: " + str(text.date_cr) + "\n"
                if (str(text.iscomp) == '0'):
                    parsedData += "is not completed\n\n"
                elif (str(text.iscomp) == '1'):
                    parsedData += "was completed on " + str(text.date_comp) + "\n\n"
                else:
                    print("Couldn't get info if task is completed or not")
            await message.answer(parsedData)
        except Exception as e:
            print(e)
            await message.answer("Error can get tasks for this period")