Skip to content
This repository was archived by the owner on Dec 23, 2024. It is now read-only.
Open
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
Update set_chat_history_ttl.py
  • Loading branch information
delivrance authored May 15, 2021
commit 583ffc7c0e597bd2df6df2bb59d136bc61b6c6b4
16 changes: 6 additions & 10 deletions pyrogram/methods/chats/set_chat_history_ttl.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ async def set_chat_history_ttl(

period (``int``):
The time-to-live for the chat history.
Either 86000 for 1 day or 608000 for 1 week.
0 (zero) can be used to disable it.
Other values are not supported by Telegram.
Either 86000 for 1 day, 604800 for 1 week or 0 (zero) to disable it.

Returns:
:obj:`~pyrogram.types.Message`: On success, the generated Service Message is returned.
Expand All @@ -46,16 +44,13 @@ async def set_chat_history_ttl(
.. code-block:: python

# One Day
app.set_history_ttl("PyrogramChat", 86400)
app.set_chat_history_ttl(chat_id, 86400)

# A Week
app.set_history_ttl("PyrogramChat", 604800)
app.set_chat_history_ttl(chat_id, 604800)

# Disabling
app.set_history_ttl("PyrogramChat", 0)

Raises:
ValueError: In case the chat_id doesn't belong to a supergroup or the time-to-live isn't 1 day or week.
app.set_chat_history_ttl(chat_id, 0)
"""

r = await self.send(
Expand All @@ -66,7 +61,8 @@ async def set_chat_history_ttl(
)

for i in r.updates:
if isinstance(i, raw.types.UpdateNewChannelMessage):
if isinstance(i, (raw.types.UpdateNewMessage,
raw.types.UpdateNewChannelMessage)):
return await types.Message._parse(
self,
i.message,
Expand Down