Skip to content

Commit

Permalink
feat: added class NoteDeleted
Browse files Browse the repository at this point in the history
  • Loading branch information
yupix committed Dec 24, 2022
1 parent 2b16d8e commit b55ee05
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Added

- added `NoteDeleted` class.
- added `INoteUpdatedDeleteBody` class.
- added `INoteUpdatedDelete` class.
- `str_to_datetime` 関数を追加

### Fixed
Expand Down
26 changes: 17 additions & 9 deletions mipac/models/note.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
from mipac.exception import NotExistRequiredData
from mipac.models.lite.user import LiteUser
from mipac.models.poll import Poll
from mipac.types.note import INoteUpdated, INoteUpdatedDelete
from mipac.util import str_to_datetime

if TYPE_CHECKING:
from mipac.actions.note import ClientNoteActions
Expand All @@ -15,12 +17,20 @@
from mipac.types.emoji import ICustomEmojiLite
from mipac.types.note import INote, INoteReaction

__all__ = (
'Note',
'Follow',
'Header',
'NoteReaction',
)
__all__ = ('Note', 'Follow', 'Header', 'NoteReaction', 'NoteDeleted')


class NoteDeleted:
def __init__(self, data: INoteUpdated[INoteUpdatedDelete]) -> None:
self.__data = data

@property
def note_id(self) -> str:
return self.__data['body']['id']

@property
def deleted_at(self) -> datetime:
return str_to_datetime(self.__data['body']['body']['deleted_at'])


class Follow:
Expand Down Expand Up @@ -132,9 +142,7 @@ def id(self) -> str:

@property
def created_at(self) -> datetime:
return datetime.strptime(
self.__note['created_at'], '%Y-%m-%dT%H:%M:%S.%fZ'
)
return str_to_datetime(self.__note['created_at'])

@property
def content(self) -> str | None:
Expand Down

0 comments on commit b55ee05

Please sign in to comment.