diff --git a/Working-with-updates.md b/Working-with-updates.md new file mode 100644 index 0000000..14fb208 --- /dev/null +++ b/Working-with-updates.md @@ -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 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). \ No newline at end of file