mirror of
https://github.com/yasirarism/MissKatyPyro.git
synced 2025-12-29 09:44:50 +00:00
* Add kbbi and carbon * add blacklist command * style: format code with black and isort (#168) Format code with black and isort This commit fixes the style issues introduced inbffcf61according to the output from Black and isort. Details: https://app.deepsource.com/gh/yasirarism/MissKatyPyro/transform/4ddb51cc-a1ca-432a-95c4-1fb5388b405a/ Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com> * okk * style: format code with black and isort (#169) Format code with black and isort This commit fixes the style issues introduced in9355c09according to the output from Black and isort. Details: https://app.deepsource.com/gh/yasirarism/MissKatyPyro/transform/172890f8-d001-4812-8380-9a666a9a3bd5/ Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com> * jmm --------- Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
33 lines
No EOL
1 KiB
Python
33 lines
No EOL
1 KiB
Python
from database import dbname
|
|
from typing import List
|
|
|
|
blacklist_filtersdb = dbname["blacklistFilters"]
|
|
|
|
async def get_blacklisted_words(chat_id: int) -> List[str]:
|
|
_filters = await blacklist_filtersdb.find_one({"chat_id": chat_id})
|
|
if not _filters:
|
|
return []
|
|
return _filters["filters"]
|
|
|
|
async def save_blacklist_filter(chat_id: int, word: str):
|
|
word = word.lower().strip()
|
|
_filters = await get_blacklisted_words(chat_id)
|
|
_filters.append(word)
|
|
await blacklist_filtersdb.update_one(
|
|
{"chat_id": chat_id},
|
|
{"$set": {"filters": _filters}},
|
|
upsert=True,
|
|
)
|
|
|
|
async def delete_blacklist_filter(chat_id: int, word: str) -> bool:
|
|
filtersd = await get_blacklisted_words(chat_id)
|
|
word = word.lower().strip()
|
|
if word in filtersd:
|
|
filtersd.remove(word)
|
|
await blacklist_filtersdb.update_one(
|
|
{"chat_id": chat_id},
|
|
{"$set": {"filters": filtersd}},
|
|
upsert=True,
|
|
)
|
|
return True
|
|
return False |