Pyrogram v0.7.1#
API Revamp#
Finally, the time for a new release has come, and is big!#
This new release features a completely new way of working with Pyrogram. Forget about isinstance()
when dealing with updates: decorators, a new dispatcher, the MessageHandler and Filters classes will make Pyrogram much more usable!
New Features#
Handlers make possible to filter updates. Use the new MessageHandler to listen for messages of any kind.
A new dispatcher makes possible to register one or more handlers by using decorators or the new add_handler() method.
Use Filters to choose what messages should be passed or not to your handler functions.
Lots of new high-level types make much easier working with Messages.
You can now send photos, audios and any kind of media using just a file_id. Pyrogram’s high-level methods have been reworked to accommodate them and will also return the new Message type.
Read the updated Docs to learn more about all these new features.
Enhancements#
Now Pyrogram is able to remember peers. This means that every user or chat you’ve encountered will be saved for future usage. No further action is needed, the new syncer module will automatically take care of everything.
Is it now possible to use phone numbers with white spaces, e.g.: “39 123 456 7890”.
Pyrogram will not allow anymore starting a Client more than once, or stopping an already stopped Client.
You can now return the sms code as both string or integer from your callback function.
The api_id argument can now be passed as both string or integer.
The connection to Telegram production servers is now made on port 443.
Pyrogram now allows accessing its object fields using square brackets, e.g.:
message["from_user"]["first_name"]
is the same asmessage.from_user.first_name
.
Breaking Changes#
set_update_handler
has been deprecated, if you really want to handle raw updates (currently phasing out in favor of the new API) you need to register a RawUpdateHandler.The convenience methods such as send_photo(), send_document(), etc… will now return a Message object.
The convenience method download_media() will now accept only a Message object, a media (such as an Audio, a Sticker, a Video, etc…) or a file_id.
The api_key parameter is replaced by api_id and api_hash.