message / chat: 'msg_id()' now returns 'file_path.stem' (removed suffix)
This commit is contained in:
@@ -194,8 +194,9 @@ class Chat:
|
||||
def msg_find(self, msg_names: list[str]) -> list[Message]:
|
||||
"""
|
||||
Search and return the messages with the given names. Names can either be filenames
|
||||
(with or without suffix) or full paths. Messages that can't be found are ignored
|
||||
(i. e. the caller should check the result if they require all messages).
|
||||
(with or without suffix), full paths or Message.msg_id(). Messages that can't be
|
||||
found are ignored (i. e. the caller should check the result if they require all
|
||||
messages).
|
||||
"""
|
||||
return [m for m in self.messages
|
||||
if any((m.file_path and self.msg_name_matches(m.file_path, mn)) for mn in msg_names)]
|
||||
@@ -203,7 +204,7 @@ class Chat:
|
||||
def msg_remove(self, msg_names: list[str]) -> None:
|
||||
"""
|
||||
Remove the messages with the given names. Names can either be filenames
|
||||
(with or without suffix) or full paths.
|
||||
(with or without suffix), full paths or Message.msg_id().
|
||||
"""
|
||||
self.messages = [m for m in self.messages
|
||||
if not any((m.file_path and self.msg_name_matches(m.file_path, mn)) for mn in msg_names)]
|
||||
@@ -389,8 +390,9 @@ class ChatDB(Chat):
|
||||
) -> list[Message]:
|
||||
"""
|
||||
Search and return the messages with the given names. Names can either be filenames
|
||||
(with or without suffix) or full paths. Messages that can't be found are ignored
|
||||
(i. e. the caller should check the result if they require all messages).
|
||||
(with or without suffix), full paths or Message.msg_id(). Messages that can't be
|
||||
found are ignored (i. e. the caller should check the result if they require all
|
||||
messages).
|
||||
Searches one of the following sources:
|
||||
* 'mem' : messages currently in memory
|
||||
* 'disk' : messages on disk (cache + DB directory), but not in memory
|
||||
@@ -405,8 +407,8 @@ class ChatDB(Chat):
|
||||
def msg_remove(self, msg_names: list[str]) -> None:
|
||||
"""
|
||||
Remove the messages with the given names. Names can either be filenames
|
||||
(with or without suffix) or full paths. Also deletes the files of all given
|
||||
messages with a valid file_path.
|
||||
(with or without suffix), full paths or Message.msg_id(). Also deletes the
|
||||
files of all given messages with a valid file_path.
|
||||
"""
|
||||
# delete the message files first
|
||||
rm_messages = self.msg_find(msg_names, source='all')
|
||||
|
||||
Reference in New Issue
Block a user