diff --git a/tbot/twitch_bot/functions/quotes.py b/tbot/twitch_bot/functions/quotes.py index 0dc2107..4a6989c 100644 --- a/tbot/twitch_bot/functions/quotes.py +++ b/tbot/twitch_bot/functions/quotes.py @@ -56,11 +56,14 @@ async def quote_delete(bot, channel_id, cmd, args, **kwargs): raise Send_error('This quote is deleted') await bot.db.execute( - 'UPDATE twitch_quotes SET ' - 'enabled=0 ' + 'DELETE FROM twitch_quotes ' 'WHERE channel_id=%s AND number=%s', (channel_id, args[0],) ) + await bot.db.execute( + 'update twitch_quotes set number = number - 1 where channel_id=%s and number>%s', + (channel_id, args[0],) + ) raise Send_error('Quote deleted') diff --git a/tbot/web/handlers/api/twitch/quotes.py b/tbot/web/handlers/api/twitch/quotes.py index 9a38b46..f535c3e 100644 --- a/tbot/web/handlers/api/twitch/quotes.py +++ b/tbot/web/handlers/api/twitch/quotes.py @@ -75,15 +75,20 @@ async def put(self, channel_id, number): @Level(1) async def delete(self, channel_id, number): - await self.db.execute(''' - UPDATE twitch_quotes SET enabled=0 WHERE channel_id=%s and number=%s - ''', (channel_id, number,)) + await self.db.execute( + 'DELETE FROM twitch_quotes ' + 'WHERE channel_id=%s AND number=%s', + (channel_id, number,) + ) + await self.db.execute( + 'update twitch_quotes set number = number - 1 where channel_id=%s and number>%s', + (channel_id, number,) + ) self.set_status(204) async def get_quote(self, channel_id, number): cmd = await self.db.fetchone(''' - SELECT * - FROM twitch_quotes + SELECT * FROM twitch_quotes WHERE channel_id=%s and number=%s ''', (channel_id, number,)) return cmd \ No newline at end of file