mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2026-01-08 16:04:51 +00:00
Compare commits
No commits in common. "22ccee53f44e4717892e64790384bb0206aa7408" and "6c7de705ceb75053436b30514f586c480805ae82" have entirely different histories.
22ccee53f4
...
6c7de705ce
8 changed files with 1 additions and 249 deletions
|
|
@ -535,9 +535,6 @@ def pyrogram_api():
|
||||||
MessageOrigin
|
MessageOrigin
|
||||||
Photo
|
Photo
|
||||||
Thumbnail
|
Thumbnail
|
||||||
TodoCompletion
|
|
||||||
TodoList
|
|
||||||
TodoTask
|
|
||||||
Audio
|
Audio
|
||||||
AvailableEffect
|
AvailableEffect
|
||||||
Document
|
Document
|
||||||
|
|
|
||||||
|
|
@ -84,6 +84,3 @@ class MessageMediaType(AutoName):
|
||||||
|
|
||||||
PAID_MEDIA = auto()
|
PAID_MEDIA = auto()
|
||||||
"Paid media"
|
"Paid media"
|
||||||
|
|
||||||
TODO = auto()
|
|
||||||
"To-Do list media"
|
|
||||||
|
|
|
||||||
|
|
@ -135,6 +135,3 @@ class MessageServiceType(AutoName):
|
||||||
|
|
||||||
PAID_MESSAGE_PRICE_CHANGED = auto()
|
PAID_MESSAGE_PRICE_CHANGED = auto()
|
||||||
"Paid message price changed"
|
"Paid message price changed"
|
||||||
|
|
||||||
TODO_COMPLETION = auto()
|
|
||||||
"To-Do completion"
|
|
||||||
|
|
@ -55,9 +55,6 @@ from .stickerset import StickerSet
|
||||||
from .stories_privacy_rules import StoriesPrivacyRules
|
from .stories_privacy_rules import StoriesPrivacyRules
|
||||||
from .stripped_thumbnail import StrippedThumbnail
|
from .stripped_thumbnail import StrippedThumbnail
|
||||||
from .thumbnail import Thumbnail
|
from .thumbnail import Thumbnail
|
||||||
from .todo_completion import TodoCompletion
|
|
||||||
from .todo_list import TodoList
|
|
||||||
from .todo_task import TodoTask
|
|
||||||
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
|
||||||
|
|
@ -145,8 +142,5 @@ __all__ = [
|
||||||
"WallpaperSettings",
|
"WallpaperSettings",
|
||||||
"TranscribedAudio",
|
"TranscribedAudio",
|
||||||
"TranslatedText",
|
"TranslatedText",
|
||||||
"TextQuote",
|
"TextQuote"
|
||||||
"TodoCompletion",
|
|
||||||
"TodoList",
|
|
||||||
"TodoTask"
|
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -194,9 +194,6 @@ class Message(Object, Update):
|
||||||
paid_media (:obj:`~pyrogram.types.PaidMedia`, *optional*):
|
paid_media (:obj:`~pyrogram.types.PaidMedia`, *optional*):
|
||||||
Message is a paid media, information about the paid media.
|
Message is a paid media, information about the paid media.
|
||||||
|
|
||||||
todo (:obj:`~pyrogram.types.Todo`, *optional*):
|
|
||||||
Message is a todo list, information about the todo list.
|
|
||||||
|
|
||||||
sticker (:obj:`~pyrogram.types.Sticker`, *optional*):
|
sticker (:obj:`~pyrogram.types.Sticker`, *optional*):
|
||||||
Message is a sticker, information about the sticker.
|
Message is a sticker, information about the sticker.
|
||||||
|
|
||||||
|
|
@ -471,7 +468,6 @@ class Message(Object, Update):
|
||||||
document: "types.Document" = None,
|
document: "types.Document" = None,
|
||||||
photo: "types.Photo" = None,
|
photo: "types.Photo" = None,
|
||||||
paid_media: "types.PaidMedia" = None,
|
paid_media: "types.PaidMedia" = None,
|
||||||
todo: "types.Todo" = None,
|
|
||||||
sticker: "types.Sticker" = None,
|
sticker: "types.Sticker" = None,
|
||||||
animation: "types.Animation" = None,
|
animation: "types.Animation" = None,
|
||||||
game: "types.Game" = None,
|
game: "types.Game" = None,
|
||||||
|
|
@ -485,7 +481,6 @@ 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_completion: "types.TodoCompletion" = 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,
|
||||||
|
|
@ -589,7 +584,6 @@ class Message(Object, Update):
|
||||||
self.document = document
|
self.document = document
|
||||||
self.photo = photo
|
self.photo = photo
|
||||||
self.paid_media = paid_media
|
self.paid_media = paid_media
|
||||||
self.todo = todo
|
|
||||||
self.sticker = sticker
|
self.sticker = sticker
|
||||||
self.animation = animation
|
self.animation = animation
|
||||||
self.game = game
|
self.game = game
|
||||||
|
|
@ -604,7 +598,6 @@ 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_completion = todo_completion
|
|
||||||
self.invoice = invoice
|
self.invoice = invoice
|
||||||
self.story = story
|
self.story = story
|
||||||
self.video = video
|
self.video = video
|
||||||
|
|
@ -770,7 +763,6 @@ 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_completion = None
|
|
||||||
|
|
||||||
service_type = None
|
service_type = None
|
||||||
chat_join_type = None
|
chat_join_type = None
|
||||||
|
|
@ -896,7 +888,6 @@ 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,
|
||||||
|
|
@ -976,18 +967,6 @@ 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):
|
|
||||||
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
|
client.message_cache[(parsed_message.chat.id, parsed_message.id)] = parsed_message
|
||||||
|
|
||||||
|
|
@ -1025,7 +1004,6 @@ class Message(Object, Update):
|
||||||
|
|
||||||
photo = None
|
photo = None
|
||||||
paid_media = None
|
paid_media = None
|
||||||
todo = None
|
|
||||||
location = None
|
location = None
|
||||||
contact = None
|
contact = None
|
||||||
venue = None
|
venue = None
|
||||||
|
|
@ -1152,9 +1130,6 @@ class Message(Object, Update):
|
||||||
elif isinstance(media, raw.types.MessageMediaPaidMedia):
|
elif isinstance(media, raw.types.MessageMediaPaidMedia):
|
||||||
paid_media = types.PaidMedia._parse(client, media)
|
paid_media = types.PaidMedia._parse(client, media)
|
||||||
media_type = enums.MessageMediaType.PAID_MEDIA
|
media_type = enums.MessageMediaType.PAID_MEDIA
|
||||||
elif isinstance(media, raw.types.MessageMediaToDo):
|
|
||||||
todo = types.TodoList._parse(client, media, users)
|
|
||||||
media_type = enums.MessageMediaType.TODO
|
|
||||||
else:
|
else:
|
||||||
media = None
|
media = None
|
||||||
|
|
||||||
|
|
@ -1224,7 +1199,6 @@ class Message(Object, Update):
|
||||||
invert_media=message.invert_media,
|
invert_media=message.invert_media,
|
||||||
photo=photo,
|
photo=photo,
|
||||||
paid_media=paid_media,
|
paid_media=paid_media,
|
||||||
todo=todo,
|
|
||||||
location=location,
|
location=location,
|
||||||
contact=contact,
|
contact=contact,
|
||||||
venue=venue,
|
venue=venue,
|
||||||
|
|
|
||||||
|
|
@ -1,54 +0,0 @@
|
||||||
# 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
|
|
||||||
)
|
|
||||||
|
|
@ -1,71 +0,0 @@
|
||||||
# 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 TodoList(Object):
|
|
||||||
"""A list of tasks.
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
name (``str``):
|
|
||||||
Title of the todo list.
|
|
||||||
|
|
||||||
entities (List of :obj:`~pyrogram.types.MessageEntity`):
|
|
||||||
Entities in the name of the todo list.
|
|
||||||
|
|
||||||
tasks (List of :obj:`~pyrogram.types.TodoTask`):
|
|
||||||
List of tasks in the todo list.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(
|
|
||||||
self,
|
|
||||||
name: str,
|
|
||||||
entities: List["types.MessageEntity"],
|
|
||||||
tasks: List["types.TodoTask"] = None
|
|
||||||
):
|
|
||||||
super().__init__()
|
|
||||||
|
|
||||||
self.name = name
|
|
||||||
self.entities = entities
|
|
||||||
self.tasks = tasks
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def _parse(
|
|
||||||
client: "pyrogram.Client",
|
|
||||||
todo: "raw.types.TodoList",
|
|
||||||
users: Dict
|
|
||||||
) -> "TodoList":
|
|
||||||
todo_list = todo.todo
|
|
||||||
completions = todo.completions
|
|
||||||
entities = [types.MessageEntity._parse(client, entity, None) for entity in todo_list.title.entities]
|
|
||||||
entities = types.List(filter(lambda x: x is not None, entities))
|
|
||||||
tasks = [
|
|
||||||
types.TodoTask._parse(client, task, users, completions)
|
|
||||||
for task in todo_list.list
|
|
||||||
] if todo_list.list else []
|
|
||||||
return TodoList(
|
|
||||||
name=todo_list.title.text,
|
|
||||||
entities=entities,
|
|
||||||
tasks=tasks
|
|
||||||
)
|
|
||||||
|
|
@ -1,82 +0,0 @@
|
||||||
# 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, utils
|
|
||||||
from ..object import Object
|
|
||||||
|
|
||||||
|
|
||||||
class TodoTask(Object):
|
|
||||||
"""A task in a todo list.
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
name (``str``):
|
|
||||||
Title of the task.
|
|
||||||
|
|
||||||
entities (List of :obj:`~pyrogram.types.MessageEntity`):
|
|
||||||
Entities in the name of the task.
|
|
||||||
|
|
||||||
is_completed (``bool``):
|
|
||||||
True, if the task is completed.
|
|
||||||
|
|
||||||
completed_by (:obj:`~pyrogram.types.User`, *optional*):
|
|
||||||
User who completed the task.
|
|
||||||
|
|
||||||
complete_date (:obj:`~datetime.datetime`, *optional*):
|
|
||||||
Date when the task was completed.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(
|
|
||||||
self,
|
|
||||||
name: str,
|
|
||||||
entities: List["types.MessageEntity"],
|
|
||||||
is_completed: bool,
|
|
||||||
completed_by: "types.User" = None,
|
|
||||||
complete_date: "pyrogram.types.datetime" = None
|
|
||||||
):
|
|
||||||
super().__init__()
|
|
||||||
|
|
||||||
self.name = name
|
|
||||||
self.entities = entities
|
|
||||||
self.is_completed = is_completed
|
|
||||||
self.completed_by = completed_by
|
|
||||||
self.complete_date = complete_date
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def _parse(
|
|
||||||
client: "pyrogram.Client",
|
|
||||||
todo_task: "raw.types.TodoTask",
|
|
||||||
users: Dict,
|
|
||||||
completions: List["raw.types.TodoTaskCompletion"] = None
|
|
||||||
) -> "TodoTask":
|
|
||||||
entities = [types.MessageEntity._parse(client, entity, None) for entity in todo_task.title.entities]
|
|
||||||
entities = types.List(filter(lambda x: x is not None, entities))
|
|
||||||
complete = {i.id: i for i in completions} if completions else {}
|
|
||||||
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
|
|
||||||
complete_date = utils.timestamp_to_datetime(todo_completion.date) if todo_completion else None
|
|
||||||
return TodoTask(
|
|
||||||
name=todo_task.title.text,
|
|
||||||
entities=entities,
|
|
||||||
is_completed=True if todo_completion else False,
|
|
||||||
completed_by=completed_by,
|
|
||||||
complete_date=complete_date
|
|
||||||
)
|
|
||||||
Loading…
Reference in a new issue