mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2025-12-29 12:04:51 +00:00
pyrofork: Refactor TodoList
Signed-off-by: wulan17 <wulan17@komodos.id>
This commit is contained in:
parent
f631f62985
commit
fa4ffef8ff
2 changed files with 5 additions and 5 deletions
|
|
@ -68,7 +68,7 @@ class TodoList(Object):
|
||||||
) -> "TodoList":
|
) -> "TodoList":
|
||||||
todo_list = todo.todo
|
todo_list = todo.todo
|
||||||
completions = todo.completions
|
completions = todo.completions
|
||||||
entities = [types.MessageEntity._parse(client, entity, None) for entity in todo_list.title.entities]
|
entities = [types.MessageEntity._parse(client, entity, users) for entity in todo_list.title.entities]
|
||||||
entities = types.List(filter(lambda x: x is not None, entities))
|
entities = types.List(filter(lambda x: x is not None, entities))
|
||||||
tasks = [
|
tasks = [
|
||||||
types.TodoTask._parse(client, task, users, completions)
|
types.TodoTask._parse(client, task, users, completions)
|
||||||
|
|
|
||||||
|
|
@ -65,15 +65,15 @@ class TodoTask(Object):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _parse(
|
def _parse(
|
||||||
client: "pyrogram.Client",
|
client: "pyrogram.Client",
|
||||||
todo_task: "raw.types.TodoTask",
|
todo_task: "raw.types.TodoList",
|
||||||
users: Dict,
|
users: Dict,
|
||||||
completions: List["raw.types.TodoTaskCompletion"] = None
|
completions: List["raw.types.TodoCompletion"] = None
|
||||||
) -> "TodoTask":
|
) -> "TodoTask":
|
||||||
entities = [types.MessageEntity._parse(client, entity, None) for entity in todo_task.title.entities]
|
entities = [types.MessageEntity._parse(client, entity, users) for entity in todo_task.title.entities]
|
||||||
entities = types.List(filter(lambda x: x is not None, entities))
|
entities = types.List(filter(lambda x: x is not None, entities))
|
||||||
complete = {i.id: i for i in completions} if completions else {}
|
complete = {i.id: i for i in completions} if completions else {}
|
||||||
todo_completion = complete.get(todo_task.id)
|
todo_completion = complete.get(todo_task.id)
|
||||||
completed_by = types.User._parse(client, users.get(todo_completion.completed_by, None)) if todo_completion else None
|
completed_by = types.User._parse(client, users.get(getattr(todo_completion.completed_by, "user_id", None), None)) if todo_completion else None
|
||||||
complete_date = utils.timestamp_to_datetime(todo_completion.date) if todo_completion else None
|
complete_date = utils.timestamp_to_datetime(todo_completion.date) if todo_completion else None
|
||||||
return TodoTask(
|
return TodoTask(
|
||||||
id=todo_task.id,
|
id=todo_task.id,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue