Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Database:
- def __init__(self, file_name: str):
- self.database = file_name
- with open(file_name, "w") as file:
- json.dump({"word": {}, "wordr": {}, "sticker": False, "animati": {}, "media": {}}, file)
- async def save(self, update: dict):
- with open(self.database, "w") as f:
- json.dump(update, f)
- async def load(self):
- with open(self.database, "r") as f:
- return json.load(f)
- async def add_word(self, word: str, risposta: str):
- update = self.load()
- update["word"][str(word)] = risposta
- await self.save(update)
- return risposta
- async def add_wordr(self, word: str, risposta: str):
- update = self.load()
- update["wordr"][str(word)] = risposta
- await self.save(update)
- return risposta
- async def add_word_media(self, word: str, risposta):
- update = self.load()
- update["media"][str(word)] = risposta
- await self.save(update)
- return risposta
- async def add_word_animate(self, word: str, risposta: list):
- update = self.load()
- update["animati"][str(word)] = risposta
- await self.save(update)
- return risposta
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement