Skip to content

Commit

Permalink
Delete the quote instead of keeping it hidden and update the number o…
Browse files Browse the repository at this point in the history
…f the quotes above the deleted one
  • Loading branch information
thomaserlang committed Aug 18, 2024
1 parent 4720d37 commit b28b2f3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
7 changes: 5 additions & 2 deletions tbot/twitch_bot/functions/quotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down
15 changes: 10 additions & 5 deletions tbot/web/handlers/api/twitch/quotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit b28b2f3

Please sign in to comment.