This commit is contained in:
2025-02-16 20:07:02 -05:00
parent bb59b5a457
commit 9df3b37619
17 changed files with 196 additions and 56 deletions

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python3.12
import os
import logging
from typing import Optional, LiteralString
from typing import LiteralString, Optional, Union
import aiosqlite as sqlite3
from constructors import LoveHateException
@ -47,16 +47,18 @@ class DB:
return result
async def get_lovehates(self, loves: bool = False, hates: bool = False,
user: Optional[str] = None, thing: Optional[str] = None) -> list[tuple]|bool:
user: Optional[str] = None, thing: Optional[str] = None) -> Union[list[tuple], bool]:
"""
Get a list of either 1) what {user} loves/hates, or who loves/hates {thing}, depending on bools loves, hates
Args:
loves (bool): Are we looking for loves?
hates (bool): ...OR are we looking for hates?
user (Optional[str]): the user to query against
thing (Optional[str]): ... OR the thing to query against
Returns:
list[tuple]|bool
Union[list[tuple], bool]
"""
query: str = ""
@ -94,6 +96,7 @@ class DB:
async def check_existence(self, user: str, thing: str) -> Optional[int]:
"""
Determine whether a user is opinionated on a <thing>
Args:
user (str): The user to check
thing (str): The thing to check if the user has an opinion on
@ -114,6 +117,7 @@ class DB:
async def update(self, user: str, thing: str, flag: int) -> str:
"""
Updates the lovehate database, and returns an appropriate response
Args:
user (str): The user to update
thing (str): The thing the user loves/hates/doesn't care about anymore