From 1e6be28e4b2cafd60d94eab881d966ef809630fa Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Sun, 22 Aug 2021 13:46:26 +0200 Subject: [PATCH] Fix pin_message not returning Message on PMs --- telethon/client/messages.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/telethon/client/messages.py b/telethon/client/messages.py index 1cb829c0..2a6a283e 100644 --- a/telethon/client/messages.py +++ b/telethon/client/messages.py @@ -1360,7 +1360,7 @@ class MessageMethods: notify (`bool`, optional): Whether the pin should notify people or not. - + pm_oneside (`bool`, optional): Whether the message should be pinned for everyone or not. By default it has the opposite behaviour of official clients, @@ -1421,12 +1421,11 @@ class MessageMethods: ) result = await self(request) - # Unpinning does not produce a service message - if unpin: - return - - # Pinning in User chats (just with yourself really) does not produce a service message - if helpers._entity_type(entity) == helpers._EntityType.USER: + # Unpinning does not produce a service message. + # Pinning a message that was already pinned also produces no service message. + # Pinning a message in your own chat does not produce a service message, + # but pinning on a private conversation with someone else does. + if unpin or not result.updates: return # Pinning a message that doesn't exist would RPC-error earlier