From ae3f88cc7253a29c5fca87113ec88bd84de9c292 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 31 Jul 2020 16:16:18 +0200 Subject: [PATCH] Prevent duplicate mmresponses from being inserted --- royalpack/utils/mmtask.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/royalpack/utils/mmtask.py b/royalpack/utils/mmtask.py index 0d0f3cbc..3c92f076 100644 --- a/royalpack/utils/mmtask.py +++ b/royalpack/utils/mmtask.py @@ -5,6 +5,7 @@ import logging import datetime import enum import asyncio as aio +import psycopg2 from telegram import InlineKeyboardMarkup as InKM from telegram import InlineKeyboardButton as InKB @@ -179,7 +180,10 @@ class MMTask: else: # Change their response mmresponse.choice = choice - await data.session_commit() + try: + await data.session_commit() + except psycopg2.Error: + raise rc.UserError("Hai giĆ  risposto nello stesso modo a questo matchmaking.") await self.telegram_channel_message_update()