mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2025-12-29 03:54:51 +00:00
pyrofork: Add TodoCompletion message service
Some checks failed
Build-docs / build (push) Has been cancelled
Pyrofork / build (macos-latest, 3.10) (push) Has been cancelled
Pyrofork / build (macos-latest, 3.11) (push) Has been cancelled
Pyrofork / build (macos-latest, 3.12) (push) Has been cancelled
Pyrofork / build (macos-latest, 3.13) (push) Has been cancelled
Pyrofork / build (macos-latest, 3.9) (push) Has been cancelled
Pyrofork / build (ubuntu-latest, 3.10) (push) Has been cancelled
Pyrofork / build (ubuntu-latest, 3.11) (push) Has been cancelled
Pyrofork / build (ubuntu-latest, 3.12) (push) Has been cancelled
Pyrofork / build (ubuntu-latest, 3.13) (push) Has been cancelled
Pyrofork / build (ubuntu-latest, 3.9) (push) Has been cancelled
Some checks failed
Build-docs / build (push) Has been cancelled
Pyrofork / build (macos-latest, 3.10) (push) Has been cancelled
Pyrofork / build (macos-latest, 3.11) (push) Has been cancelled
Pyrofork / build (macos-latest, 3.12) (push) Has been cancelled
Pyrofork / build (macos-latest, 3.13) (push) Has been cancelled
Pyrofork / build (macos-latest, 3.9) (push) Has been cancelled
Pyrofork / build (ubuntu-latest, 3.10) (push) Has been cancelled
Pyrofork / build (ubuntu-latest, 3.11) (push) Has been cancelled
Pyrofork / build (ubuntu-latest, 3.12) (push) Has been cancelled
Pyrofork / build (ubuntu-latest, 3.13) (push) Has been cancelled
Pyrofork / build (ubuntu-latest, 3.9) (push) Has been cancelled
Signed-off-by: wulan17 <wulan17@komodos.id>
This commit is contained in:
parent
989ce836d3
commit
22ccee53f4
5 changed files with 76 additions and 0 deletions
|
|
@ -535,6 +535,7 @@ def pyrogram_api():
|
|||
MessageOrigin
|
||||
Photo
|
||||
Thumbnail
|
||||
TodoCompletion
|
||||
TodoList
|
||||
TodoTask
|
||||
Audio
|
||||
|
|
|
|||
|
|
@ -135,3 +135,6 @@ class MessageServiceType(AutoName):
|
|||
|
||||
PAID_MESSAGE_PRICE_CHANGED = auto()
|
||||
"Paid message price changed"
|
||||
|
||||
TODO_COMPLETION = auto()
|
||||
"To-Do completion"
|
||||
|
|
@ -55,6 +55,7 @@ from .stickerset import StickerSet
|
|||
from .stories_privacy_rules import StoriesPrivacyRules
|
||||
from .stripped_thumbnail import StrippedThumbnail
|
||||
from .thumbnail import Thumbnail
|
||||
from .todo_completion import TodoCompletion
|
||||
from .todo_list import TodoList
|
||||
from .todo_task import TodoTask
|
||||
from .venue import Venue
|
||||
|
|
@ -145,6 +146,7 @@ __all__ = [
|
|||
"TranscribedAudio",
|
||||
"TranslatedText",
|
||||
"TextQuote",
|
||||
"TodoCompletion",
|
||||
"TodoList",
|
||||
"TodoTask"
|
||||
]
|
||||
|
|
|
|||
|
|
@ -485,6 +485,7 @@ class Message(Object, Update):
|
|||
gift: "types.Gift" = None,
|
||||
screenshot_taken: "types.ScreenshotTaken" = None,
|
||||
paid_message_price_changed: "types.PaidMessagePriceChanged" = None,
|
||||
todo_completion: "types.TodoCompletion" = None,
|
||||
invoice: "types.Invoice" = None,
|
||||
story: Union["types.MessageStory", "types.Story"] = None,
|
||||
alternative_videos: List["types.AlternativeVideo"] = None,
|
||||
|
|
@ -603,6 +604,7 @@ class Message(Object, Update):
|
|||
self.gift = gift
|
||||
self.screenshot_taken = screenshot_taken
|
||||
self.paid_message_price_changed = paid_message_price_changed
|
||||
self.todo_completion = todo_completion
|
||||
self.invoice = invoice
|
||||
self.story = story
|
||||
self.video = video
|
||||
|
|
@ -768,6 +770,7 @@ class Message(Object, Update):
|
|||
gift = None
|
||||
screenshot_taken = None
|
||||
paid_message_price_changed = None
|
||||
todo_completion = None
|
||||
|
||||
service_type = None
|
||||
chat_join_type = None
|
||||
|
|
@ -893,6 +896,7 @@ class Message(Object, Update):
|
|||
paid_message_price_changed = types.PaidMessagePriceChanged._parse(action)
|
||||
service_type = enums.MessageServiceType.PAID_MESSAGE_PRICE_CHANGED
|
||||
|
||||
|
||||
parsed_message = Message(
|
||||
id=message.id,
|
||||
message_thread_id=message_thread_id,
|
||||
|
|
@ -972,6 +976,18 @@ class Message(Object, Update):
|
|||
parsed_message.service = enums.MessageServiceType.GAME_HIGH_SCORE
|
||||
except MessageIdsEmpty:
|
||||
pass
|
||||
if isinstance(action, raw.types.MessageActionTodoCompletions):
|
||||
parsed_message.todo_completion = types.TodoCompletion._parse(action)
|
||||
parsed_message.service_type = enums.MessageServiceType.TODO_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
|
||||
|
||||
client.message_cache[(parsed_message.chat.id, parsed_message.id)] = parsed_message
|
||||
|
||||
|
|
|
|||
54
pyrogram/types/messages_and_media/todo_completion.py
Normal file
54
pyrogram/types/messages_and_media/todo_completion.py
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
# 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, Dict
|
||||
|
||||
import pyrogram
|
||||
from pyrogram import raw, types
|
||||
from ..object import Object
|
||||
|
||||
|
||||
class TodoCompletion(Object):
|
||||
"""A todo completion.
|
||||
|
||||
Parameters:
|
||||
id (``int``):
|
||||
Unique identifier of the todo tasks.
|
||||
|
||||
is_completed (``bool``):
|
||||
True, if the todo tasks is completed.
|
||||
"""
|
||||
|
||||
def __init__(self, id: int, is_completed: bool):
|
||||
super().__init__()
|
||||
|
||||
self.id = id
|
||||
self.is_completed = is_completed
|
||||
|
||||
@staticmethod
|
||||
def _parse(todo_completion: "raw.types.TodoCompletion") -> "TodoCompletion":
|
||||
if todo_completion.completed:
|
||||
return TodoCompletion(
|
||||
id=todo_completion.completed[0],
|
||||
is_completed=True
|
||||
)
|
||||
return TodoCompletion(
|
||||
id=todo_completion.incompleted[0],
|
||||
is_completed=False
|
||||
)
|
||||
Loading…
Reference in a new issue