mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2025-12-29 12:04:51 +00:00
pyrofork: Add Todo message service
Signed-off-by: wulan17 <wulan17@komodos.id>
This commit is contained in:
parent
e54b991cea
commit
92b831812f
7 changed files with 202 additions and 1 deletions
|
|
@ -537,6 +537,9 @@ def pyrogram_api():
|
||||||
Thumbnail
|
Thumbnail
|
||||||
TodoList
|
TodoList
|
||||||
TodoTask
|
TodoTask
|
||||||
|
TodoTasksAdded
|
||||||
|
TodoTasksCompleted
|
||||||
|
TodoTasksIncompleted
|
||||||
Audio
|
Audio
|
||||||
AvailableEffect
|
AvailableEffect
|
||||||
Document
|
Document
|
||||||
|
|
|
||||||
|
|
@ -135,3 +135,9 @@ class MessageServiceType(AutoName):
|
||||||
|
|
||||||
PAID_MESSAGE_PRICE_CHANGED = auto()
|
PAID_MESSAGE_PRICE_CHANGED = auto()
|
||||||
"Paid message price changed"
|
"Paid message price changed"
|
||||||
|
|
||||||
|
TODO_TASKS_ADDED = auto()
|
||||||
|
"To-Do tasks added"
|
||||||
|
|
||||||
|
TODO_TASKS_COMPLETION = auto()
|
||||||
|
"To-Do tasks completion/incompletion"
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,9 @@ from .stripped_thumbnail import StrippedThumbnail
|
||||||
from .thumbnail import Thumbnail
|
from .thumbnail import Thumbnail
|
||||||
from .todo_list import TodoList
|
from .todo_list import TodoList
|
||||||
from .todo_task import TodoTask
|
from .todo_task import TodoTask
|
||||||
|
from .todo_tasks_added import TodoTasksAdded
|
||||||
|
from .todo_tasks_completed import TodoTasksCompleted
|
||||||
|
from .todo_tasks_incompleted import TodoTasksIncompleted
|
||||||
from .venue import Venue
|
from .venue import Venue
|
||||||
from .video import Video
|
from .video import Video
|
||||||
from .video_note import VideoNote
|
from .video_note import VideoNote
|
||||||
|
|
@ -146,5 +149,8 @@ __all__ = [
|
||||||
"TranslatedText",
|
"TranslatedText",
|
||||||
"TextQuote",
|
"TextQuote",
|
||||||
"TodoList",
|
"TodoList",
|
||||||
"TodoTask"
|
"TodoTask",
|
||||||
|
"TodoTasksAdded",
|
||||||
|
"TodoTasksCompleted",
|
||||||
|
"TodoTasksIncompleted"
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -407,6 +407,21 @@ class Message(Object, Update):
|
||||||
gifted_premium (:obj:`~pyrogram.types.GiftedPremium`, *optional*):
|
gifted_premium (:obj:`~pyrogram.types.GiftedPremium`, *optional*):
|
||||||
Info about a gifted Telegram Premium subscription
|
Info about a gifted Telegram Premium subscription
|
||||||
|
|
||||||
|
screenshot_taken (:obj:`~pyrogram.types.ScreenshotTaken`, *optional*):
|
||||||
|
Service message: screenshot taken.
|
||||||
|
|
||||||
|
paid_message_price_changed (:obj:`~pyrogram.types.PaidMessagePriceChanged`, *optional*):
|
||||||
|
Service message: paid message price changed.
|
||||||
|
|
||||||
|
todo_tasks_added (:obj:`~pyrogram.types.TodoTasksAdded`, *optional*):
|
||||||
|
Service message: todo tasks added.
|
||||||
|
|
||||||
|
todo_tasks_completed (:obj:`~pyrogram.types.TodoTasksCompleted`, *optional*):
|
||||||
|
Service message: todo tasks completed.
|
||||||
|
|
||||||
|
todo_tasks_incompleted (:obj:`~pyrogram.types.TodoTasksIncompleted`, *optional*):
|
||||||
|
Service message: todo tasks incompleted.
|
||||||
|
|
||||||
link (``str``, *property*):
|
link (``str``, *property*):
|
||||||
Generate a link to this message, only for groups and channels.
|
Generate a link to this message, only for groups and channels.
|
||||||
|
|
||||||
|
|
@ -485,6 +500,9 @@ class Message(Object, Update):
|
||||||
gift: "types.Gift" = None,
|
gift: "types.Gift" = None,
|
||||||
screenshot_taken: "types.ScreenshotTaken" = None,
|
screenshot_taken: "types.ScreenshotTaken" = None,
|
||||||
paid_message_price_changed: "types.PaidMessagePriceChanged" = None,
|
paid_message_price_changed: "types.PaidMessagePriceChanged" = None,
|
||||||
|
todo_tasks_added: "types.TodoTasksAdded" = None,
|
||||||
|
todo_tasks_completed: "types.TodoTasksCompleted" = None,
|
||||||
|
todo_tasks_incompleted: "types.TodoTasksIncompleted" = None,
|
||||||
invoice: "types.Invoice" = None,
|
invoice: "types.Invoice" = None,
|
||||||
story: Union["types.MessageStory", "types.Story"] = None,
|
story: Union["types.MessageStory", "types.Story"] = None,
|
||||||
alternative_videos: List["types.AlternativeVideo"] = None,
|
alternative_videos: List["types.AlternativeVideo"] = None,
|
||||||
|
|
@ -603,6 +621,9 @@ class Message(Object, Update):
|
||||||
self.gift = gift
|
self.gift = gift
|
||||||
self.screenshot_taken = screenshot_taken
|
self.screenshot_taken = screenshot_taken
|
||||||
self.paid_message_price_changed = paid_message_price_changed
|
self.paid_message_price_changed = paid_message_price_changed
|
||||||
|
self.todo_tasks_added = todo_tasks_added
|
||||||
|
self.todo_tasks_completed = todo_tasks_completed
|
||||||
|
self.todo_tasks_incompleted = todo_tasks_incompleted
|
||||||
self.invoice = invoice
|
self.invoice = invoice
|
||||||
self.story = story
|
self.story = story
|
||||||
self.video = video
|
self.video = video
|
||||||
|
|
@ -768,6 +789,9 @@ class Message(Object, Update):
|
||||||
gift = None
|
gift = None
|
||||||
screenshot_taken = None
|
screenshot_taken = None
|
||||||
paid_message_price_changed = None
|
paid_message_price_changed = None
|
||||||
|
todo_tasks_added = None
|
||||||
|
todo_tasks_completed = None
|
||||||
|
todo_tasks_incompleted = None
|
||||||
|
|
||||||
service_type = None
|
service_type = None
|
||||||
chat_join_type = None
|
chat_join_type = None
|
||||||
|
|
@ -893,6 +917,7 @@ class Message(Object, Update):
|
||||||
paid_message_price_changed = types.PaidMessagePriceChanged._parse(action)
|
paid_message_price_changed = types.PaidMessagePriceChanged._parse(action)
|
||||||
service_type = enums.MessageServiceType.PAID_MESSAGE_PRICE_CHANGED
|
service_type = enums.MessageServiceType.PAID_MESSAGE_PRICE_CHANGED
|
||||||
|
|
||||||
|
|
||||||
parsed_message = Message(
|
parsed_message = Message(
|
||||||
id=message.id,
|
id=message.id,
|
||||||
message_thread_id=message_thread_id,
|
message_thread_id=message_thread_id,
|
||||||
|
|
@ -972,6 +997,34 @@ class Message(Object, Update):
|
||||||
parsed_message.service = enums.MessageServiceType.GAME_HIGH_SCORE
|
parsed_message.service = enums.MessageServiceType.GAME_HIGH_SCORE
|
||||||
except MessageIdsEmpty:
|
except MessageIdsEmpty:
|
||||||
pass
|
pass
|
||||||
|
if isinstance(action, raw.types.MessageActionTodoCompletions):
|
||||||
|
if action.completed:
|
||||||
|
parsed_message.todo_tasks_completed = types.TodoTasksCompleted._parse(action)
|
||||||
|
if action.incompleted:
|
||||||
|
parsed_message.todo_tasks_incompleted = types.TodoTasksIncompleted._parse(action)
|
||||||
|
parsed_message.service_type = enums.MessageServiceType.TODO_TASKS_COMPLETION
|
||||||
|
try:
|
||||||
|
parsed_message.reply_to_message = await client.get_messages(
|
||||||
|
parsed_message.chat.id,
|
||||||
|
reply_to_message_ids=message.id,
|
||||||
|
replies=0
|
||||||
|
)
|
||||||
|
except MessageIdsEmpty:
|
||||||
|
pass
|
||||||
|
parsed_message.reply_to_message_id = message.reply_to.reply_to_msg_id
|
||||||
|
|
||||||
|
if isinstance(action, raw.types.MessageActionTodoAppendTasks):
|
||||||
|
parsed_message.todo_tasks_added = types.TodoTasksAdded._parse(client, action)
|
||||||
|
parsed_message.service = enums.MessageServiceType.TODO_TASKS_ADDED
|
||||||
|
try:
|
||||||
|
parsed_message.reply_to_message = await client.get_messages(
|
||||||
|
parsed_message.chat.id,
|
||||||
|
reply_to_message_ids=message.id,
|
||||||
|
replies=0
|
||||||
|
)
|
||||||
|
except MessageIdsEmpty:
|
||||||
|
pass
|
||||||
|
parsed_message.reply_to_message_id = message.reply_to.reply_to_msg_id
|
||||||
|
|
||||||
client.message_cache[(parsed_message.chat.id, parsed_message.id)] = parsed_message
|
client.message_cache[(parsed_message.chat.id, parsed_message.id)] = parsed_message
|
||||||
|
|
||||||
|
|
|
||||||
45
pyrogram/types/messages_and_media/todo_tasks_added.py
Normal file
45
pyrogram/types/messages_and_media/todo_tasks_added.py
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
# Pyrofork - Telegram MTProto API Client Library for Python
|
||||||
|
# Copyright (C) 2022-present Mayuri-Chan <https://github.com/Mayuri-Chan>
|
||||||
|
#
|
||||||
|
# This file is part of Pyrofork.
|
||||||
|
#
|
||||||
|
# Pyrofork is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Lesser General Public License as published
|
||||||
|
# by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# Pyrofork is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Lesser General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
|
# along with Pyrofork. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import pyrogram
|
||||||
|
|
||||||
|
from pyrogram import raw, types
|
||||||
|
from ..object import Object
|
||||||
|
|
||||||
|
|
||||||
|
class TodoTasksAdded(Object):
|
||||||
|
"""A todo task added to a todo list.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
task (:obj:`~pyrogram.types.TodoTask`):
|
||||||
|
The added todo task.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, tasks: "types.TodoTask"):
|
||||||
|
super().__init__()
|
||||||
|
|
||||||
|
self.tasks = tasks
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _parse(
|
||||||
|
client: "pyrogram.Client",
|
||||||
|
todo_task_added: "raw.types.MessageActionTodoAppendTasks"
|
||||||
|
) -> "TodoTasksAdded":
|
||||||
|
return TodoTasksAdded(
|
||||||
|
tasks=[types.TodoTask._parse(client, task, {}, {}) for task in todo_task_added.list]
|
||||||
|
)
|
||||||
44
pyrogram/types/messages_and_media/todo_tasks_completed.py
Normal file
44
pyrogram/types/messages_and_media/todo_tasks_completed.py
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
# Pyrofork - Telegram MTProto API Client Library for Python
|
||||||
|
# Copyright (C) 2022-present Mayuri-Chan <https://github.com/Mayuri-Chan>
|
||||||
|
#
|
||||||
|
# This file is part of Pyrofork.
|
||||||
|
#
|
||||||
|
# Pyrofork is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Lesser General Public License as published
|
||||||
|
# by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# Pyrofork is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Lesser General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
|
# along with Pyrofork. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
|
from typing import List
|
||||||
|
|
||||||
|
from pyrogram import raw
|
||||||
|
from ..object import Object
|
||||||
|
|
||||||
|
|
||||||
|
class TodoTasksCompleted(Object):
|
||||||
|
"""One or more todo task/s has been flag as complete.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
ids (List of ``int``):
|
||||||
|
List of Unique identifier of the todo tasks.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, ids: List[int]):
|
||||||
|
super().__init__()
|
||||||
|
|
||||||
|
self.ids = ids
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _parse(todo_completion: "raw.types.TodoCompletion") -> "TodoTasksCompleted":
|
||||||
|
ids = [id for id in todo_completion.completed]
|
||||||
|
return TodoTasksCompleted(
|
||||||
|
ids=ids,
|
||||||
|
)
|
||||||
44
pyrogram/types/messages_and_media/todo_tasks_incompleted.py
Normal file
44
pyrogram/types/messages_and_media/todo_tasks_incompleted.py
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
# Pyrofork - Telegram MTProto API Client Library for Python
|
||||||
|
# Copyright (C) 2022-present Mayuri-Chan <https://github.com/Mayuri-Chan>
|
||||||
|
#
|
||||||
|
# This file is part of Pyrofork.
|
||||||
|
#
|
||||||
|
# Pyrofork is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Lesser General Public License as published
|
||||||
|
# by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# Pyrofork is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Lesser General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
|
# along with Pyrofork. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
|
from typing import List
|
||||||
|
|
||||||
|
from pyrogram import raw
|
||||||
|
from ..object import Object
|
||||||
|
|
||||||
|
|
||||||
|
class TodoTasksIncompleted(Object):
|
||||||
|
"""One or more todo task/s has been flag as incomplete.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
ids (List of ``int``):
|
||||||
|
List of Unique identifier of the todo tasks.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, ids: List[int]):
|
||||||
|
super().__init__()
|
||||||
|
|
||||||
|
self.ids = ids
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _parse(todo_completion: "raw.types.TodoCompletion") -> "TodoTasksIncompleted":
|
||||||
|
ids = [id for id in todo_completion.incompleted]
|
||||||
|
return TodoTasksIncompleted(
|
||||||
|
ids=ids,
|
||||||
|
)
|
||||||
Loading…
Reference in a new issue