From bc104e89157fd398c01a13a636d4a6d5a4452ab9 Mon Sep 17 00:00:00 2001 From: Yasir Aris M Date: Thu, 23 Nov 2023 11:01:17 +0700 Subject: [PATCH] Fix notes and filters for old data --- misskaty/plugins/filters.py | 6 +++--- misskaty/plugins/notes.py | 24 ++++++++++++------------ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/misskaty/plugins/filters.py b/misskaty/plugins/filters.py index 15df24ac..de4dc0f7 100644 --- a/misskaty/plugins/filters.py +++ b/misskaty/plugins/filters.py @@ -169,9 +169,9 @@ async def filters_re(_, message): pattern = r"( |^|[^\w])" + re.escape(word) + r"( |$|[^\w])" if re.search(pattern, text, flags=re.IGNORECASE): _filter = await get_filter(chat_id, word) - data_type = _filter["type"] - data = _filter["data"] - file_id = _filter["file_id"] + data_type = _filter.get("type") + data = _filter.get("data") + file_id = _filter.get("file_id") keyb = None if data: if re.findall(r"\[.+\,.+\]", data): diff --git a/misskaty/plugins/notes.py b/misskaty/plugins/notes.py index 47648794..5ef2b856 100644 --- a/misskaty/plugins/notes.py +++ b/misskaty/plugins/notes.py @@ -146,9 +146,9 @@ async def get_one_note(self, message): self.log.info(_note) if not _note: return - type = _note["type"] - data = _note["data"] - file_id = _note["file_id"] + type_ = _note.get("type") + data = _note.get("data") + file_id = _note.get("file_id") keyb = None if data: if findall(r"\[.+\,.+\]", data): @@ -159,51 +159,51 @@ async def get_one_note(self, message): if replied_message: if replied_message.from_user.id != message.from_user.id: message = replied_message - if type == "text": + if type_ == "text": await message.reply_text( text=data, reply_markup=keyb, disable_web_page_preview=True, ) - if type == "sticker": + if type_ == "sticker": await message.reply_sticker( sticker=file_id, ) - if type == "animation": + if type_ == "animation": await message.reply_animation( animation=file_id, caption=data, reply_markup=keyb, ) - if type == "photo": + if type_ == "photo": await message.reply_photo( photo=file_id, caption=data, reply_markup=keyb, ) - if type == "document": + if type_ == "document": await message.reply_document( document=file_id, caption=data, reply_markup=keyb, ) - if type == "video": + if type_ == "video": await message.reply_video( video=file_id, caption=data, reply_markup=keyb, ) - if type == "video_note": + if type_ == "video_note": await message.reply_video_note( video_note=file_id, ) - if type == "audio": + if type_ == "audio": await message.reply_audio( audio=file_id, caption=data, reply_markup=keyb, ) - if type == "voice": + if type_ == "voice": await message.reply_voice( voice=file_id, caption=data,