Skip to content
This repository was archived by the owner on Dec 23, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Addressing requested changes
`set_history_ttl` -> `set_chat_history_ttl` in all occurences
  • Loading branch information
ColinShark committed May 14, 2021
commit bf5882579e0b99963663a6023c1ad6855f061ba6
4 changes: 2 additions & 2 deletions pyrogram/methods/chats/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
from .unpin_chat_message import UnpinChatMessage
from .update_chat_username import UpdateChatUsername
from .get_chat_online_count import GetChatOnlineCount
from .set_history_ttl import SetHistoryTTL
from .set_chat_history_ttl import SetChatHistoryTTL


class Chats(
Expand Down Expand Up @@ -96,6 +96,6 @@ class Chats(
MarkChatUnread,
GetChatEventLog,
GetChatOnlineCount,
SetHistoryTTL,
SetChatHistoryTTL,
):
pass
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
from pyrogram.scaffold import Scaffold


class SetHistoryTTL(Scaffold):
async def set_history_ttl(
class SetChatHistoryTTL(Scaffold):
async def set_chat_history_ttl(
self, chat_id: Union[int, str], period: int
) -> "types.Message":
"""Set the time-to-live for the chat history.
Expand Down Expand Up @@ -58,26 +58,18 @@ async def set_history_ttl(
ValueError: In case the chat_id doesn't belong to a supergroup or the time-to-live isn't 1 day or week.
"""

peer = await self.resolve_peer(chat_id)
if not isinstance(peer, raw.types.InputPeerChannel):
raise ValueError(f'The chat_id "{chat_id}" does not belong to a channel')

if period not in (0, 86400, 604800):
raise ValueError(f'The time-to-live "{period}" needs to be either 86400 (1 day) or 604800 (1 week).')

else:
r = await self.send(
raw.functions.messages.SetHistoryTTL(
peer=await self.resolve_peer(chat_id),
period=period,
)
r = await self.send(
raw.functions.messages.SetHistoryTTL(
peer=await self.resolve_peer(chat_id),
period=period,
)

for i in r.updates:
if isinstance(i, raw.types.UpdateNewChannelMessage):
return await types.Message._parse(
self,
i.message,
{i.id: i for i in r.users},
{i.id: i for i in r.chats},
)
)

for i in r.updates:
if isinstance(i, raw.types.UpdateNewChannelMessage):
return await types.Message._parse(
self,
i.message,
{i.id: i for i in r.users},
{i.id: i for i in r.chats},
)
12 changes: 6 additions & 6 deletions pyrogram/types/messages_and_media/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ def __init__(
voice_chat_started: "types.VoiceChatStarted" = None,
voice_chat_ended: "types.VoiceChatEnded" = None,
voice_chat_members_invited: "types.VoiceChatMembersInvited" = None,
history_ttl: int = None,
chat_history_ttl: int = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
"types.ReplyKeyboardMarkup",
Expand Down Expand Up @@ -424,7 +424,7 @@ def __init__(
self.voice_chat_started = voice_chat_started
self.voice_chat_ended = voice_chat_ended
self.voice_chat_members_invited = voice_chat_members_invited
self.history_ttl = history_ttl
self.chat_history_ttl = chat_history_ttl

@staticmethod
async def _parse(
Expand Down Expand Up @@ -454,7 +454,7 @@ async def _parse(
voice_chat_started = None
voice_chat_ended = None
voice_chat_members_invited = None
history_ttl = None
chat_history_ttl = None

service_type = None

Expand Down Expand Up @@ -502,8 +502,8 @@ async def _parse(
voice_chat_members_invited = types.VoiceChatMembersInvited._parse(client, action, users)
service_type = "voice_chat_members_invited"
elif isinstance(action, raw.types.MessageActionSetMessagesTTL):
history_ttl = action.period
service_type = "history_ttl"
chat_history_ttl = action.period
service_type = "chat_history_ttl"

user = utils.get_raw_peer_id(message.from_id) or utils.get_raw_peer_id(message.peer_id)
from_user = types.User._parse(client, users.get(user, None))
Expand All @@ -529,7 +529,7 @@ async def _parse(
voice_chat_started=voice_chat_started,
voice_chat_ended=voice_chat_ended,
voice_chat_members_invited=voice_chat_members_invited,
history_ttl=history_ttl,
chat_history_ttl=chat_history_ttl,
client=client
# TODO: supergroup_chat_created
)
Expand Down