mirror of
				https://github.com/LonamiWebs/Telethon.git
				synced 2025-11-04 01:47:27 +03:00 
			
		
		
		
	Note that .get_entity supports joinchat/ links
							parent
							
								
									4e44c4fbc1
								
							
						
					
					
						commit
						de19eb3bb5
					
				| 
						 | 
				
			
			@ -1,6 +1,12 @@
 | 
			
		|||
An "entity" is used to refer to either an [`User`](https://lonamiwebs.github.io/Telethon/types/user.html) or a [`Chat`](https://lonamiwebs.github.io/Telethon/types/chat.html) (which includes a [`Channel`](https://lonamiwebs.github.io/Telethon/constructors/channel.html)). The most straightforward way to get an entity is to use `TelegramClient.get_entity()`. This method accepts either a string, which can be a username or a phone number, or an integer that will be the ID of an **user**. You can use it like so:
 | 
			
		||||
An "entity" is used to refer to either an [`User`](https://lonamiwebs.github.io/Telethon/types/user.html) or a [`Chat`](https://lonamiwebs.github.io/Telethon/types/chat.html) (which includes a [`Channel`](https://lonamiwebs.github.io/Telethon/constructors/channel.html)). The most straightforward way to get an entity is to use `TelegramClient.get_entity()`. This method accepts either a string, which can be a username, phone number or [t.me](https://t.me)-like link, or an integer that will be the ID of an **user**. You can use it like so:
 | 
			
		||||
```python
 | 
			
		||||
# all of these work
 | 
			
		||||
lonami  = client.get_entity('lonami')
 | 
			
		||||
lonami  = client.get_entity('t.me/lonami')
 | 
			
		||||
lonami  = client.get_entity('https://telegram.dog/lonami')
 | 
			
		||||
 | 
			
		||||
# other kind of entities
 | 
			
		||||
channel = client.get_entity('telegram.me/joinchat/AAAAAEkk2WdoDrB4-Q8-gg')
 | 
			
		||||
contact = client.get_entity('+34xxxxxxxxx')
 | 
			
		||||
friend  = client.get_entity(friend_id)
 | 
			
		||||
```
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user