mirror of
https://github.com/yasirarism/MissKatyPyro.git
synced 2025-12-29 17:44:50 +00:00
* style: format code with isort, Ruff Formatter and Yapf This commit fixes the style issues introduced inf9f107eaccording to the output from isort, Ruff Formatter and Yapf. Details: None * refactor: autofix issues in 2 files Resolved issues in the following files with DeepSource Autofix: 1. misskaty/plugins/download_upload.py 2. misskaty/plugins/nightmodev2.py * style: format code with isort, Ruff Formatter and Yapf This commit fixes the style issues introduced in1bc1345according to the output from isort, Ruff Formatter and Yapf. Details: https://github.com/yasirarism/MissKatyPyro/pull/300 * refactor: autofix issues in 2 files Resolved issues in the following files with DeepSource Autofix: 1. misskaty/plugins/dev.py 2. misskaty/plugins/misc_tools.py * style: format code with isort, Ruff Formatter and Yapf This commit fixes the style issues introduced in58d2f1aaccording to the output from isort, Ruff Formatter and Yapf. Details: https://github.com/yasirarism/MissKatyPyro/pull/300 --------- Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com> Co-authored-by: Yasir Aris M <git@yasirdev.my.id>
48 lines
1.2 KiB
Python
48 lines
1.2 KiB
Python
from typing import Dict, List, Union
|
|
|
|
from database import dbname
|
|
|
|
notesdb = dbname["notes"]
|
|
|
|
|
|
async def _get_notes(chat_id: int) -> Dict[str, int]:
|
|
_notes = await notesdb.find_one({"chat_id": chat_id})
|
|
return _notes["notes"] if _notes else {}
|
|
|
|
|
|
async def delete_note(chat_id: int, name: str) -> bool:
|
|
notesd = await _get_notes(chat_id)
|
|
name = name.lower().strip()
|
|
if name in notesd:
|
|
del notesd[name]
|
|
await notesdb.update_one(
|
|
{"chat_id": chat_id},
|
|
{"$set": {"notes": notesd}},
|
|
upsert=True,
|
|
)
|
|
return True
|
|
return False
|
|
|
|
|
|
async def get_note(chat_id: int, name: str) -> Union[bool, dict]:
|
|
name = name.lower().strip()
|
|
_notes = await _get_notes(chat_id)
|
|
return _notes[name] if name in _notes else False
|
|
|
|
|
|
async def get_note_names(chat_id: int) -> List[str]:
|
|
return list(await _get_notes(chat_id))
|
|
|
|
|
|
async def save_note(chat_id: int, name: str, note: dict):
|
|
name = name.lower().strip()
|
|
_notes = await _get_notes(chat_id)
|
|
_notes[name] = note
|
|
|
|
await notesdb.update_one(
|
|
{"chat_id": chat_id}, {"$set": {"notes": _notes}}, upsert=True
|
|
)
|
|
|
|
|
|
async def deleteall_notes(chat_id: int):
|
|
return await notesdb.delete_one({"chat_id": chat_id})
|