backend + telegram: добавлена обработка ошибок при регистрации

This commit is contained in:
2022-11-18 01:31:17 +03:00
parent a6fba9e3a0
commit 02685d28df
3 changed files with 31 additions and 12 deletions

View File

@@ -22,8 +22,15 @@ async def start(message):
"last_name": tg_user.last_name,
"username": tg_user.username,
}
backend.post("/registration", ts_user)
await message.reply("Nice!")
result = backend.post("/registration", ts_user)
if not result["error"] and result["response"].ok:
data = json.loads(result["response"].text)
if data["created"]:
await message.reply("Добро пожаловать!")
else:
await message.reply("Добро пожаловать! Снова")
else:
await message.reply("Упс! Что-то пошло не так")
if __name__ == "__main__":