Pyrogram v0.10.2#

Layer 91, Lots of New Features and Internal Changes for the Better#

Happy New Year 2019!#

This last update of the year turns out to be the biggest ever made, featuring quite important internal changes – which worth mentioning – as well as lots of new additions. More updates will come in the future, such as the work-in-progress inline mode. Keep Pyrogramming!

Under the Hood#

  • Refactored types: Pyrogram types have been rewritten from scratch using cleaner code which increases maintainability and readability and also allows future extensibility with ease.

  • Type hints: Pyrogram type and method parameters are now type hinted. This means that, with smart IDEs, whenever you try to access any Pyrogram object field you will be hinted about all the available options.

What’s New#

  • API schema updated to Layer 91.

  • Normal bots (created by BotFather) are now able to send messages to all the users who contacted them in the past anytime just by their IDs. Bots can also send messages to group chats and channels they are members of without having to manually kick and re-add them again. Thanks Manuel and TDLib devs in PyrogramLounge for suggesting this was possible!

  • Normal bots are now able to edit and delete their own messages via Message’s bound methods .edit() and .delete().

  • New Message.web_page attribute for messages sent with web page previews. Note that support for web pages is still basic; a simple boolean is set in case the message contains a web page preview. In future versions this attribute could turn into a full web page object that contains more details. (contributed by @zeroone2numeral2 in #166).

  • New Filters.web_page to filter messages containing web page previews (contributed by @zeroone2numeral2 in #166).

  • New Filters.via_bot to filter messages coming from inline bots.

  • Client.start() and Client.stop() will now return the Client instance itself to make chaining possible.

  • Sticker packs are now automatically cached once they are retrieved for the first time. This change increases Message parsing performance a lot in case there are many stickers in a chat coming from the same pack.

  • First name of users/bots is now shown when logging in the first time.

  • It is now possible to recover password-protected accounts at login time (only if a password recovery e-mail was previously set) Thanks @hoolihoolihooli for testing with me in PyrogramChat.

  • New Poll and PollOption objects which represent the new native polls in Telegram among with send_poll, vote_poll and retract_vote methods to interact with polls and Filters.poll to filter messages containing polls.

  • Pin/unpin_chat_message method has been updated to work on basic groups and users’ own private chats as well (previously working on channels and supergroups only).

  • New hide_via argument for send_inline_bot_result used to hide via @bot captions (currently doesn’t work as official clients or the server itself seem to ignore this).

  • get_history is now able to return Messages in reversed (natural) order with the new reversed parameters set to True (contributed by @YoilyL in #94).

  • New get_chat_preview method, which can be used to get the preview of a chat you haven’t joined yet by its invite link; the new ChatPreview object will be returned. get_chat has been modified as well to accept invite links of already joined chats. All other methods, such as send_message, still need the chat_id as integer to work in private groups and channels (you can take that from get_chat’s result).

  • Many new common Telegram errors have been added.

  • Three new documentation sections: Test Servers, Advanced Usage and Changelog.

  • The future branch is now gone, all changes have been merged into the default develop branch, meaning this update contains all of them!

Bug Fixes#

  • The raw update handler was handling parsed updates (contributed by @Jafte in #159).

  • Videos sent inside an album were ignoring the custom thumbnails.

  • download_media was not working properly in case of empty progress_args.

  • A download progress callback was always reporting 0 as current bytes in case of downloads from file ids.

  • Fixed a critical bug which caused random errors because of dicts not keeping keys order for Python <3.6.

Breaking Changes#

  • Yet another subtle update that changes how current callback queries work: CallbackQuery.data type is now bytes instead of str, because of Telegram API actually allowing clients to send arbitrary bytes; forcing the decoding to turn bytes data into strings could lead to errors.

  • get_dialogs now expects an offset_date as integer instead of a Dialog chunk as offset.