mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-28 12:23:45 +03:00
Created Working with updates (markdown)
parent
3604433ebb
commit
ceff88c6c7
22
Working-with-updates.md
Normal file
22
Working-with-updates.md
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
**Important note**: Updates are currently handled in a **passive** way, so **not all may be received**. Read below for more information.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
The most minimal example to receive updates, and often what you will need if processing updates is all you need, is as follows:
|
||||||
|
```python
|
||||||
|
def update_handler(update_object):
|
||||||
|
# On this example, we just show the update object itself
|
||||||
|
print(update_object)
|
||||||
|
|
||||||
|
|
||||||
|
# From now on, any update received will be passed to 'update_handler'
|
||||||
|
client.add_update_handler(update_handler)
|
||||||
|
|
||||||
|
input('Press <ENTER> to exit...')
|
||||||
|
client.disconnect()
|
||||||
|
```
|
||||||
|
|
||||||
|
The `update_object` may be any instance of [`Updates`](https://lonamiwebs.github.io/Telethon/types/updates.html) or even a single [`Update`](https://lonamiwebs.github.io/Telethon/types/update.html), so you have absolute control about which updates you want to handle and which you don't. `isinstance(update_object, SomeClass)` may probe very useful here.
|
||||||
|
|
||||||
|
## Note follow-up
|
||||||
|
The library currently handles all updates in a **passive** way, so not all updates may be received. This is, all it does is listen to what the server sends. It will **not** run things like [`GetDifferenceRequest`](https://lonamiwebs.github.io/Telethon/methods/updates/get_difference.html) or take into consideration the methods that return more [`Updates`](https://lonamiwebs.github.io/Telethon/types/updates.html).
|
Loading…
Reference in New Issue
Block a user