mirror of
				https://github.com/LonamiWebs/Telethon.git
				synced 2025-11-04 01:47:27 +03:00 
			
		
		
		
	Use InputMessageReplyTo in get_reply_message
This lets bots access to messages other bots sent through replies.
This commit is contained in:
		
							parent
							
								
									9a6f4d35f2
								
							
						
					
					
						commit
						ed1bcb509f
					
				| 
						 | 
					@ -506,10 +506,21 @@ class Message(ChatGetter, SenderGetter, TLObject, abc.ABC):
 | 
				
			||||||
            if not self.reply_to_msg_id:
 | 
					            if not self.reply_to_msg_id:
 | 
				
			||||||
                return None
 | 
					                return None
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            # Bots cannot access other bots' messages by their ID.
 | 
				
			||||||
 | 
					            # However they can access them through replies...
 | 
				
			||||||
            self._reply_message = await self._client.get_messages(
 | 
					            self._reply_message = await self._client.get_messages(
 | 
				
			||||||
                await self.get_input_chat() if self.is_channel else None,
 | 
					                await self.get_input_chat() if self.is_channel else None,
 | 
				
			||||||
                ids=self.reply_to_msg_id
 | 
					                ids=types.InputMessageReplyTo(self.id)
 | 
				
			||||||
            )
 | 
					            )
 | 
				
			||||||
 | 
					            if not self._reply_message:
 | 
				
			||||||
 | 
					                # ...unless the current message got deleted.
 | 
				
			||||||
 | 
					                #
 | 
				
			||||||
 | 
					                # If that's the case, give it a second chance accessing
 | 
				
			||||||
 | 
					                # directly by its ID.
 | 
				
			||||||
 | 
					                self._reply_message = await self._client.get_messages(
 | 
				
			||||||
 | 
					                    self._input_chat if self.is_channel else None,
 | 
				
			||||||
 | 
					                    ids=self.reply_to_msg_id
 | 
				
			||||||
 | 
					                )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return self._reply_message
 | 
					        return self._reply_message
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user