mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2026-01-08 16:04:51 +00:00
Compare commits
2 commits
5413197003
...
22ccee53f4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
22ccee53f4 | ||
|
|
989ce836d3 |
15 changed files with 46 additions and 492 deletions
|
|
@ -165,7 +165,6 @@ def pyrogram_api():
|
||||||
""",
|
""",
|
||||||
messages="""
|
messages="""
|
||||||
Messages
|
Messages
|
||||||
add_task_to_todo
|
|
||||||
send_message
|
send_message
|
||||||
forward_media_group
|
forward_media_group
|
||||||
forward_messages
|
forward_messages
|
||||||
|
|
@ -175,7 +174,6 @@ def pyrogram_api():
|
||||||
send_audio
|
send_audio
|
||||||
send_document
|
send_document
|
||||||
send_sticker
|
send_sticker
|
||||||
send_todo
|
|
||||||
send_video
|
send_video
|
||||||
send_animation
|
send_animation
|
||||||
send_voice
|
send_voice
|
||||||
|
|
@ -187,7 +185,6 @@ def pyrogram_api():
|
||||||
send_contact
|
send_contact
|
||||||
send_cached_media
|
send_cached_media
|
||||||
send_reaction
|
send_reaction
|
||||||
set_todo_tasks_completion
|
|
||||||
edit_message_text
|
edit_message_text
|
||||||
edit_message_caption
|
edit_message_caption
|
||||||
edit_message_media
|
edit_message_media
|
||||||
|
|
@ -538,11 +535,9 @@ def pyrogram_api():
|
||||||
MessageOrigin
|
MessageOrigin
|
||||||
Photo
|
Photo
|
||||||
Thumbnail
|
Thumbnail
|
||||||
|
TodoCompletion
|
||||||
TodoList
|
TodoList
|
||||||
TodoTask
|
TodoTask
|
||||||
TodoTasksAdded
|
|
||||||
TodoTasksCompleted
|
|
||||||
TodoTasksIncompleted
|
|
||||||
Audio
|
Audio
|
||||||
AvailableEffect
|
AvailableEffect
|
||||||
Document
|
Document
|
||||||
|
|
@ -742,7 +737,6 @@ def pyrogram_api():
|
||||||
InputVenueMessageContent
|
InputVenueMessageContent
|
||||||
InputContactMessageContent
|
InputContactMessageContent
|
||||||
InputInvoiceMessageContent
|
InputInvoiceMessageContent
|
||||||
InputTodoTask
|
|
||||||
""",
|
""",
|
||||||
authorization="""
|
authorization="""
|
||||||
Authorization
|
Authorization
|
||||||
|
|
|
||||||
|
|
@ -136,8 +136,5 @@ 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()
|
TODO_COMPLETION = auto()
|
||||||
"To-Do tasks added"
|
"To-Do completion"
|
||||||
|
|
||||||
TODO_TASKS_COMPLETION = auto()
|
|
||||||
"To-Do tasks completion/incompletion"
|
|
||||||
|
|
@ -17,7 +17,6 @@
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with Pyrofork. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrofork. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from .add_task_to_todo import AddTaskToTodo
|
|
||||||
from .copy_media_group import CopyMediaGroup
|
from .copy_media_group import CopyMediaGroup
|
||||||
from .copy_message import CopyMessage
|
from .copy_message import CopyMessage
|
||||||
from .delete_chat_history import DeleteChatHistory
|
from .delete_chat_history import DeleteChatHistory
|
||||||
|
|
@ -53,7 +52,6 @@ from .search_global_hashtag_messages import SearchGlobalHashtagMessages
|
||||||
from .search_global_hashtag_messages_count import SearchGlobalHashtagMessagesCount
|
from .search_global_hashtag_messages_count import SearchGlobalHashtagMessagesCount
|
||||||
from .search_messages import SearchMessages
|
from .search_messages import SearchMessages
|
||||||
from .search_messages_count import SearchMessagesCount
|
from .search_messages_count import SearchMessagesCount
|
||||||
from .set_todo_tasks_completion import SetTodoTasksCompletion
|
|
||||||
from .send_animation import SendAnimation
|
from .send_animation import SendAnimation
|
||||||
from .send_audio import SendAudio
|
from .send_audio import SendAudio
|
||||||
from .send_cached_media import SendCachedMedia
|
from .send_cached_media import SendCachedMedia
|
||||||
|
|
@ -68,7 +66,6 @@ from .send_photo import SendPhoto
|
||||||
from .send_poll import SendPoll
|
from .send_poll import SendPoll
|
||||||
from .send_reaction import SendReaction
|
from .send_reaction import SendReaction
|
||||||
from .send_sticker import SendSticker
|
from .send_sticker import SendSticker
|
||||||
from .send_todo import SendTodo
|
|
||||||
from .send_venue import SendVenue
|
from .send_venue import SendVenue
|
||||||
from .send_video import SendVideo
|
from .send_video import SendVideo
|
||||||
from .send_video_note import SendVideoNote
|
from .send_video_note import SendVideoNote
|
||||||
|
|
@ -82,7 +79,6 @@ from .transcribe_audio import TranscribeAudio
|
||||||
from .translate_text import TranslateText
|
from .translate_text import TranslateText
|
||||||
|
|
||||||
class Messages(
|
class Messages(
|
||||||
AddTaskToTodo,
|
|
||||||
DeleteChatHistory,
|
DeleteChatHistory,
|
||||||
DeleteMessages,
|
DeleteMessages,
|
||||||
DeleteScheduledMessages,
|
DeleteScheduledMessages,
|
||||||
|
|
@ -97,7 +93,6 @@ class Messages(
|
||||||
GetMessages,
|
GetMessages,
|
||||||
GetMessageReadParticipants,
|
GetMessageReadParticipants,
|
||||||
GetScheduledMessages,
|
GetScheduledMessages,
|
||||||
SetTodoTasksCompletion,
|
|
||||||
SendAudio,
|
SendAudio,
|
||||||
SendChatAction,
|
SendChatAction,
|
||||||
SendContact,
|
SendContact,
|
||||||
|
|
@ -108,7 +103,6 @@ class Messages(
|
||||||
SendMessage,
|
SendMessage,
|
||||||
SendPhoto,
|
SendPhoto,
|
||||||
SendSticker,
|
SendSticker,
|
||||||
SendTodo,
|
|
||||||
SendVenue,
|
SendVenue,
|
||||||
SendVideo,
|
SendVideo,
|
||||||
SendVideoNote,
|
SendVideoNote,
|
||||||
|
|
|
||||||
|
|
@ -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/>.
|
|
||||||
|
|
||||||
import pyrogram
|
|
||||||
|
|
||||||
from pyrogram import raw, types, utils
|
|
||||||
from typing import Union, List
|
|
||||||
|
|
||||||
|
|
||||||
class AddTaskToTodo:
|
|
||||||
async def add_task_to_todo(
|
|
||||||
self: "pyrogram.Client",
|
|
||||||
chat_id: Union[int, str],
|
|
||||||
message_id: Union[int, str],
|
|
||||||
tasks: List["types.InputTodoTask"],
|
|
||||||
parse_mode: str = None
|
|
||||||
) -> "types.Message":
|
|
||||||
"""Add tasks to a todo list.
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
chat_id (``int`` | ``str``):
|
|
||||||
Unique identifier for the target chat or username of the target channel.
|
|
||||||
|
|
||||||
message_id (``int`` | ``str``):
|
|
||||||
Unique identifier for the target message or username of the target channel.
|
|
||||||
|
|
||||||
tasks (List of :obj:`~pyrogram.types.InputTodoTask`):
|
|
||||||
List of tasks to be added to the todo list.
|
|
||||||
|
|
||||||
parse_mode (``str``, *optional*):
|
|
||||||
The parse mode to use for formatting the text.
|
|
||||||
|
|
||||||
entities (List of :obj:`~pyrogram.types.MessageEntity`, *optional*):
|
|
||||||
Entities in the title of the todo list.
|
|
||||||
"""
|
|
||||||
tasks_list = []
|
|
||||||
get_message = await self.get_messages(chat_id, message_id)
|
|
||||||
if not isinstance(get_message, types.Message):
|
|
||||||
raise ValueError("The message must be a valid Message object.")
|
|
||||||
todo_list = get_message.todo
|
|
||||||
last_task_id = max((task.id for task in todo_list.tasks), default=0)
|
|
||||||
for i, task in enumerate(tasks):
|
|
||||||
task_title, task_entities = (await utils.parse_text_entities(self, task.title, parse_mode, task.entities)).values()
|
|
||||||
tasks_list.append(
|
|
||||||
raw.types.TodoItem(
|
|
||||||
id=last_task_id + i + 1,
|
|
||||||
title=raw.types.TextWithEntities(
|
|
||||||
text=task_title,
|
|
||||||
entities=task_entities or []
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
r = await self.invoke(
|
|
||||||
raw.functions.messages.AppendTodoList(
|
|
||||||
peer=await self.resolve_peer(chat_id),
|
|
||||||
msg_id=message_id,
|
|
||||||
list=tasks_list
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
for update in r.updates:
|
|
||||||
if isinstance(update, (raw.types.UpdateNewMessage,
|
|
||||||
raw.types.UpdateNewChannelMessage,
|
|
||||||
raw.types.UpdateNewScheduledMessage,
|
|
||||||
raw.types.UpdateBotNewBusinessMessage)):
|
|
||||||
return types.Message._parse(self, update.message, update, r.users, r.chats)
|
|
||||||
|
|
@ -1,99 +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/>.
|
|
||||||
|
|
||||||
import pyrogram
|
|
||||||
|
|
||||||
from pyrogram import raw, types, utils
|
|
||||||
from typing import Union, List
|
|
||||||
|
|
||||||
|
|
||||||
class SendTodo:
|
|
||||||
async def send_todo(
|
|
||||||
self: "pyrogram.Client",
|
|
||||||
chat_id: Union[int, str],
|
|
||||||
title: str,
|
|
||||||
tasks: List["types.InputTodoTask"],
|
|
||||||
entities: List["types.MessageEntity"] = None,
|
|
||||||
can_append: bool = False,
|
|
||||||
can_complete: bool = False,
|
|
||||||
parse_mode: Union[str, None] = None
|
|
||||||
):
|
|
||||||
"""Send a todo list to a chat.
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
chat_id (``int`` | ``str``):
|
|
||||||
Unique identifier for the target chat or username of the target channel.
|
|
||||||
|
|
||||||
title (``str``):
|
|
||||||
Title of the todo list.
|
|
||||||
|
|
||||||
tasks (List of :obj:`~pyrogram.types.TodoTask`):
|
|
||||||
List of tasks in the todo list.
|
|
||||||
|
|
||||||
entities (List of :obj:`~pyrogram.types.MessageEntity`, *optional*):
|
|
||||||
Entities in the title of the todo list.
|
|
||||||
|
|
||||||
can_append (``bool``, *optional*):
|
|
||||||
True, if other users can append tasks to this todo list.
|
|
||||||
|
|
||||||
can_complete (``bool``, *optional*):
|
|
||||||
True, if other users can complete tasks in this todo list.
|
|
||||||
"""
|
|
||||||
title, entities = (await utils.parse_text_entities(self, title, parse_mode, entities)).values()
|
|
||||||
tasks_list = []
|
|
||||||
for i, task in enumerate(tasks):
|
|
||||||
task_title, task_entities = (await utils.parse_text_entities(self, task.title, parse_mode, task.entities)).values()
|
|
||||||
tasks_list.append(
|
|
||||||
raw.types.TodoItem(
|
|
||||||
id=i + 1,
|
|
||||||
title=raw.types.TextWithEntities(
|
|
||||||
text=task_title,
|
|
||||||
entities=task_entities or []
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
r = await self.invoke(
|
|
||||||
raw.functions.messages.SendMedia(
|
|
||||||
peer=await self.resolve_peer(chat_id),
|
|
||||||
message="",
|
|
||||||
random_id=self.rnd_id(),
|
|
||||||
media=raw.types.InputMediaTodo(
|
|
||||||
todo=raw.types.TodoList(
|
|
||||||
title=raw.types.TextWithEntities(
|
|
||||||
text=title,
|
|
||||||
entities=entities or []
|
|
||||||
),
|
|
||||||
list=tasks_list,
|
|
||||||
others_can_append=can_append,
|
|
||||||
others_can_complete=can_complete
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
for i in r.updates:
|
|
||||||
if isinstance(i, (raw.types.UpdateNewMessage,
|
|
||||||
raw.types.UpdateNewChannelMessage,
|
|
||||||
raw.types.UpdateNewScheduledMessage,
|
|
||||||
raw.types.UpdateBotNewBusinessMessage)):
|
|
||||||
return await types.Message._parse(
|
|
||||||
self, i.message,
|
|
||||||
{i.id: i for i in r.users},
|
|
||||||
{i.id: i for i in r.chats},
|
|
||||||
is_scheduled=isinstance(i, raw.types.UpdateNewScheduledMessage)
|
|
||||||
)
|
|
||||||
|
|
@ -1,76 +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, Union
|
|
||||||
from pyrogram import raw, types
|
|
||||||
|
|
||||||
|
|
||||||
class SetTodoTasksCompletion:
|
|
||||||
async def set_todo_tasks_completion(
|
|
||||||
self,
|
|
||||||
chat_id: int | str,
|
|
||||||
message_id: int,
|
|
||||||
completed_ids: Union[int, List[int]] = None,
|
|
||||||
incompleted_ids: Union[int, List[int]] = None
|
|
||||||
) -> "types.Message":
|
|
||||||
"""Set the completion status of one or more todo tasks.
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
chat_id (``int`` | ``str``):
|
|
||||||
Unique identifier (int) or username (str) of the target chat.
|
|
||||||
|
|
||||||
message_id (``int``):
|
|
||||||
Unique identifier of the message containing the todo list.
|
|
||||||
|
|
||||||
completed_ids (``int`` | List of ``int``, *optional*):
|
|
||||||
Unique identifier of the todo tasks to be marked as completed.
|
|
||||||
If a list is provided, all tasks in the list will be marked as completed.
|
|
||||||
|
|
||||||
incompleted_ids (``int`` | List of ``int``, *optional*):
|
|
||||||
Unique identifier of the todo tasks to be marked as incomplete.
|
|
||||||
If a list is provided, all tasks in the list will be marked as incomplete.
|
|
||||||
"""
|
|
||||||
is_complete_iterable = None
|
|
||||||
is_incomplete_iterable = None
|
|
||||||
if completed_ids:
|
|
||||||
is_complete_iterable = not isinstance(completed_ids, int)
|
|
||||||
if incompleted_ids:
|
|
||||||
is_incomplete_iterable = not isinstance(incompleted_ids, int)
|
|
||||||
if not is_complete_iterable and not is_incomplete_iterable:
|
|
||||||
raise ValueError("At least one of completed_ids or incompleted_ids must be provided.")
|
|
||||||
|
|
||||||
r = await self.invoke(
|
|
||||||
raw.functions.messages.ToggleTodoCompleted(
|
|
||||||
peer=await self.resolve_peer(chat_id),
|
|
||||||
msg_id=message_id,
|
|
||||||
completed=(completed_ids if is_complete_iterable else [completed_ids]) if completed_ids else [],
|
|
||||||
incompleted=(incompleted_ids if is_incomplete_iterable else [incompleted_ids]) if incompleted_ids else []
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
for i in r.updates:
|
|
||||||
if isinstance(i, (raw.types.UpdateNewMessage,
|
|
||||||
raw.types.UpdateNewChannelMessage,
|
|
||||||
raw.types.UpdateNewScheduledMessage,
|
|
||||||
raw.types.UpdateBotNewBusinessMessage)):
|
|
||||||
return await types.Message._parse(
|
|
||||||
self, i.message,
|
|
||||||
{i.id: i for i in r.users},
|
|
||||||
{i.id: i for i in r.chats},
|
|
||||||
is_scheduled=isinstance(i, raw.types.UpdateNewScheduledMessage)
|
|
||||||
)
|
|
||||||
|
|
@ -26,7 +26,6 @@ from .input_location_message_content import InputLocationMessageContent
|
||||||
from .input_venue_message_content import InputVenueMessageContent
|
from .input_venue_message_content import InputVenueMessageContent
|
||||||
from .input_contact_message_content import InputContactMessageContent
|
from .input_contact_message_content import InputContactMessageContent
|
||||||
from .input_invoice_message_content import InputInvoiceMessageContent
|
from .input_invoice_message_content import InputInvoiceMessageContent
|
||||||
from .input_todo_task import InputTodoTask
|
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"InputMessageContent",
|
"InputMessageContent",
|
||||||
|
|
@ -37,6 +36,5 @@ __all__ = [
|
||||||
"InputLocationMessageContent",
|
"InputLocationMessageContent",
|
||||||
"InputVenueMessageContent",
|
"InputVenueMessageContent",
|
||||||
"InputContactMessageContent",
|
"InputContactMessageContent",
|
||||||
"InputInvoiceMessageContent",
|
"InputInvoiceMessageContent"
|
||||||
"InputTodoTask"
|
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -1,37 +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 ..object import Object
|
|
||||||
|
|
||||||
|
|
||||||
class InputTodoTask(Object):
|
|
||||||
"""Contains information about a todo task.
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
title (``str``):
|
|
||||||
Title of the task.
|
|
||||||
|
|
||||||
entities (List of :obj:`~pyrogram.types.MessageEntity`):
|
|
||||||
Entities in the title of the task.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, *, title: str, entities: list = None):
|
|
||||||
super().__init__()
|
|
||||||
|
|
||||||
self.title = title
|
|
||||||
self.entities = entities
|
|
||||||
|
|
@ -55,11 +55,9 @@ 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_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
|
||||||
|
|
@ -148,9 +146,7 @@ __all__ = [
|
||||||
"TranscribedAudio",
|
"TranscribedAudio",
|
||||||
"TranslatedText",
|
"TranslatedText",
|
||||||
"TextQuote",
|
"TextQuote",
|
||||||
|
"TodoCompletion",
|
||||||
"TodoList",
|
"TodoList",
|
||||||
"TodoTask",
|
"TodoTask"
|
||||||
"TodoTasksAdded",
|
|
||||||
"TodoTasksCompleted",
|
|
||||||
"TodoTasksIncompleted"
|
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -407,21 +407,6 @@ 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.
|
||||||
|
|
||||||
|
|
@ -500,9 +485,7 @@ 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_completion: "types.TodoCompletion" = 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,
|
||||||
|
|
@ -621,9 +604,7 @@ 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_completion = todo_completion
|
||||||
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
|
||||||
|
|
@ -789,9 +770,7 @@ 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_completion = None
|
||||||
todo_tasks_completed = None
|
|
||||||
todo_tasks_incompleted = None
|
|
||||||
|
|
||||||
service_type = None
|
service_type = None
|
||||||
chat_join_type = None
|
chat_join_type = None
|
||||||
|
|
@ -998,24 +977,8 @@ class Message(Object, Update):
|
||||||
except MessageIdsEmpty:
|
except MessageIdsEmpty:
|
||||||
pass
|
pass
|
||||||
if isinstance(action, raw.types.MessageActionTodoCompletions):
|
if isinstance(action, raw.types.MessageActionTodoCompletions):
|
||||||
if action.completed:
|
parsed_message.todo_completion = types.TodoCompletion._parse(action)
|
||||||
parsed_message.todo_tasks_completed = types.TodoTasksCompleted._parse(action)
|
parsed_message.service_type = enums.MessageServiceType.TODO_COMPLETION
|
||||||
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:
|
try:
|
||||||
parsed_message.reply_to_message = await client.get_messages(
|
parsed_message.reply_to_message = await client.get_messages(
|
||||||
parsed_message.chat.id,
|
parsed_message.chat.id,
|
||||||
|
|
|
||||||
|
|
@ -17,28 +17,38 @@
|
||||||
# along with Pyrofork. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrofork. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
from typing import List
|
from typing import List, Dict
|
||||||
|
|
||||||
from pyrogram import raw
|
import pyrogram
|
||||||
|
from pyrogram import raw, types
|
||||||
from ..object import Object
|
from ..object import Object
|
||||||
|
|
||||||
|
|
||||||
class TodoTasksIncompleted(Object):
|
class TodoCompletion(Object):
|
||||||
"""One or more todo task/s has been flag as incomplete.
|
"""A todo completion.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
ids (List of ``int``):
|
id (``int``):
|
||||||
List of Unique identifier of the todo tasks.
|
Unique identifier of the todo tasks.
|
||||||
|
|
||||||
|
is_completed (``bool``):
|
||||||
|
True, if the todo tasks is completed.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, ids: List[int]):
|
def __init__(self, id: int, is_completed: bool):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
self.ids = ids
|
self.id = id
|
||||||
|
self.is_completed = is_completed
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _parse(todo_completion: "raw.types.TodoCompletion") -> "TodoTasksIncompleted":
|
def _parse(todo_completion: "raw.types.TodoCompletion") -> "TodoCompletion":
|
||||||
ids = [id for id in todo_completion.incompleted]
|
if todo_completion.completed:
|
||||||
return TodoTasksIncompleted(
|
return TodoCompletion(
|
||||||
ids=ids,
|
id=todo_completion.completed[0],
|
||||||
|
is_completed=True
|
||||||
|
)
|
||||||
|
return TodoCompletion(
|
||||||
|
id=todo_completion.incompleted[0],
|
||||||
|
is_completed=False
|
||||||
)
|
)
|
||||||
|
|
@ -28,37 +28,27 @@ class TodoList(Object):
|
||||||
"""A list of tasks.
|
"""A list of tasks.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
title (``str``):
|
name (``str``):
|
||||||
Title of the todo list.
|
Title of the todo list.
|
||||||
|
|
||||||
entities (List of :obj:`~pyrogram.types.MessageEntity`):
|
entities (List of :obj:`~pyrogram.types.MessageEntity`):
|
||||||
Entities in the title of the todo list.
|
Entities in the name of the todo list.
|
||||||
|
|
||||||
tasks (List of :obj:`~pyrogram.types.TodoTask`):
|
tasks (List of :obj:`~pyrogram.types.TodoTask`):
|
||||||
List of tasks in the todo list.
|
List of tasks in the todo list.
|
||||||
|
|
||||||
can_append (``bool``, optional):
|
|
||||||
True, if other users can append tasks to this todo list.
|
|
||||||
|
|
||||||
can_complete (``bool``, optional):
|
|
||||||
True, if other users can complete tasks in this todo list.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
title: str,
|
name: str,
|
||||||
entities: List["types.MessageEntity"],
|
entities: List["types.MessageEntity"],
|
||||||
tasks: List["types.TodoTask"] = None,
|
tasks: List["types.TodoTask"] = None
|
||||||
can_append: bool = False,
|
|
||||||
can_complete: bool = False
|
|
||||||
):
|
):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
self.title = title
|
self.name = name
|
||||||
self.entities = entities
|
self.entities = entities
|
||||||
self.tasks = tasks
|
self.tasks = tasks
|
||||||
self.can_append = can_append
|
|
||||||
self.can_complete = can_complete
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _parse(
|
def _parse(
|
||||||
|
|
@ -75,9 +65,7 @@ class TodoList(Object):
|
||||||
for task in todo_list.list
|
for task in todo_list.list
|
||||||
] if todo_list.list else []
|
] if todo_list.list else []
|
||||||
return TodoList(
|
return TodoList(
|
||||||
title=todo_list.title.text,
|
name=todo_list.title.text,
|
||||||
entities=entities,
|
entities=entities,
|
||||||
tasks=tasks,
|
tasks=tasks
|
||||||
can_append=todo_list.others_can_append,
|
|
||||||
can_complete=todo_list.others_can_complete
|
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -28,11 +28,11 @@ class TodoTask(Object):
|
||||||
"""A task in a todo list.
|
"""A task in a todo list.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
title (``str``):
|
name (``str``):
|
||||||
Title of the task.
|
Title of the task.
|
||||||
|
|
||||||
entities (List of :obj:`~pyrogram.types.MessageEntity`):
|
entities (List of :obj:`~pyrogram.types.MessageEntity`):
|
||||||
Entities in the title of the task.
|
Entities in the name of the task.
|
||||||
|
|
||||||
is_completed (``bool``):
|
is_completed (``bool``):
|
||||||
True, if the task is completed.
|
True, if the task is completed.
|
||||||
|
|
@ -46,8 +46,7 @@ class TodoTask(Object):
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
id: int,
|
name: str,
|
||||||
title: str,
|
|
||||||
entities: List["types.MessageEntity"],
|
entities: List["types.MessageEntity"],
|
||||||
is_completed: bool,
|
is_completed: bool,
|
||||||
completed_by: "types.User" = None,
|
completed_by: "types.User" = None,
|
||||||
|
|
@ -55,8 +54,7 @@ class TodoTask(Object):
|
||||||
):
|
):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
self.id = id
|
self.name = name
|
||||||
self.title = title
|
|
||||||
self.entities = entities
|
self.entities = entities
|
||||||
self.is_completed = is_completed
|
self.is_completed = is_completed
|
||||||
self.completed_by = completed_by
|
self.completed_by = completed_by
|
||||||
|
|
@ -76,8 +74,7 @@ class TodoTask(Object):
|
||||||
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(todo_completion.completed_by, 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,
|
name=todo_task.title.text,
|
||||||
title=todo_task.title.text,
|
|
||||||
entities=entities,
|
entities=entities,
|
||||||
is_completed=True if todo_completion else False,
|
is_completed=True if todo_completion else False,
|
||||||
completed_by=completed_by,
|
completed_by=completed_by,
|
||||||
|
|
|
||||||
|
|
@ -1,45 +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/>.
|
|
||||||
|
|
||||||
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]
|
|
||||||
)
|
|
||||||
|
|
@ -1,44 +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
|
|
||||||
|
|
||||||
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,
|
|
||||||
)
|
|
||||||
Loading…
Reference in a new issue