Skip to content

@delivrance delivrance released this Mar 21, 2021

New Features & Additions

About future user identifiers

You might have heard that Telegram is approaching the upper limit of the signed 32-bit integer type used for user identifiers and that future identifiers will become bigger than 2^31 - 1, and you were worried about it; there's no reason to be alarmed as this will not be a problem for Pyrogram because Python uses arbitrary precision integers and the required changes underneath will be done transparently. The issue only arises in case you are storing yourself the identifiers in fixed 32-bit chunks; in that case you need to update your system to accommodate identifiers that can have up to 52 significant bits (meaning both a 64-bit integer and double-precision float type are safe to use).

Assets 2

@delivrance delivrance released this Dec 23, 2020

Notable Changes

  • The API schema has been updated to Layer 122 adding support for group calls (voice chats), channel comments, multiple message pins, message replies and more.
  • Performance improvements: some critical parts were optimized to allow the async event loop running smoother; other parts have been optimized as well to avoid unnecessary computations.
  • Added support for the newest Bot API file ids: the file_ref parameter is now useless and has been removed from the API in favour of a single file_id parameter. A file_unique_id parameter has also been added to media types, making Pyrogram file ids 100% compatible with the Bot API. This means all file ids (old and new) you take or might have taken from the Bot API will work with Pyrogram, and vice-versa.
  • Pyrogram's raw API reference docs have been enhanced: you can now find a description to methods, types and constructors, as well as each combinator's argument (when available and applicable). This will allow people to better understand how to use the vast Telegram low-level API.
  • Pyrogram is now fully independent on the system clock. This means that any modification to the system clock will not make Pyrogram misbehave anymore because the internal clock used is now synced with Telegram servers instead.
  • Added initial automated test suites for Python 3.6, 3.7, 3.8 and 3.9 in Linux, Windows and macOS environments.
  • Added the new method copy_message and the bound method Message.copy. This will replace the feature found in forward_messages "as_copy=True" by also enhancing its behaviour.
  • Added the ability to manually pass text entities to methods instead of specifying the parse_mode.
  • Added support for anonymous messages: added the sender_chat attribute to Message objects.
  • Added support for anonymous chat members: added is_anonymous attribute to ChatMember.
  • Added the ability to search for pinned messages in a chat with search_messages.
  • Added support for InputMediaAudio and InputMediaDocument in albums. To be used to send audio and documents inside media groups.
  • Added support for multiple pins and the ability to pin messages in private chats.
  • Pyrogram objects are now pickable (contributed by @GodSaveTheDoge in #526).
  • Added bio attribute in Chat objects. When using get_chat, expect the bio attributed to be set for users and the description attribute for other chats.
  • Added the method unpin_all_chat_messages to unpin all pinned messages in a chat.
  • Added support for the new football and slot machine animations for the random dice.
  • Added the new method get_media_group (contributed by @Legenda24 in #550).
  • Improved typing hints throughout the library (contributed by @alissonlauffer in #537).
  • Added ttl_seconds support for send_video and Message.reply_video (contributed by @drizzt in #556).

Bugfixes & Enhancements

  • Made new_chat_photo downloadable (contributed by @GodSaveTheDoge #508).
  • Enhanced filters.me to allow it intercept own anonymous messages (contributed by @M-Smits in #501).
  • Added a missing parameter in Message.reply_poll (contributed by @SpEcHiDe in #507) .
  • Skip empty messages when parsing dialogs (contributed by @JosXa in #555).
  • Added a nicer error in case of unknown constructors.
  • Added schedule_date parameter to send_media_group.
  • Fixed filters.user and filters.chat breaking when no initial collection is passed.
  • Fixed idle() not working in windows.
  • Added some missing await keywords.
  • Fixed media captions being displayed as "None" for inline media results when no caption was passed.
  • Reverted to input for passwords and added the hide_password parameter to Client.
  • Added the sleep_threshold parameter to the send() method.
  • Decreased the default sleep threshold from 60 to 10 seconds.
  • Fixed some "invalid escape" warnings.
  • Enabled passing sleep_threshold=0 to always raise flood waits.
  • Fixed a bad f-string usage causing the text parser to break.
  • Fixed an issue causing inline callback queries to fail.
  • Removed TLObject as super class for base types.
  • Added the attribute dc_id to Chat objects.
  • Fixed get_profile_photos not working properly in channels.
  • Added a warning to users in case they try to use base types as arguments.
  • Fixed dispatcher not obeying to the INFO logging level.
  • Added force_document argument for send_document.
  • Fixed get_profile_photos not working correctly in case of no chat photos.
  • Fixed clock issues when running on AWS Lambda.
  • Fixed get_messages not working with list of ids in case the first message was empty.
  • Changed the default filter for get/iter_chat_members to "recent".
  • Fixed the raw API not being properly imported when using repr/eval.
  • Various improvements when using Pyrogram in a sync context.
  • Fixed sync callback progress not working properly for downloads.
Assets 2

@delivrance delivrance released this Aug 25, 2020

Welcome to Pyrogram 1.0!

Since the first release almost three years ago, we've made over 3,000 commits by continuously delivering plenty of new features and fixes, which account for more than 300,000 lines of code added, edited or removed. Thousands of developers across the world have shown their appreciation to the project by kind words praising the way Pyrogram is built and performing, by donations or by simply giving a star to the repository.

This really means a lot, and today I'm pleased to announce the next step taken towards what represents over two and a half years worth of Open Source software development and community management efforts.

What's New

Pyrogram now fully supports asynchronous handlers and filters by default. This was possible by rewriting the whole framework using asynchronous interfaces down to the TCP core level. The result is concurrent code running in a single OS-level thread allowing for greater performance.

@app.on_message(filters.private)
async def my_handler(client, message):
    await message.reply_text("Hello, async world!")

Asynchronous support is entirely backwards-compatible and transparent to users, meaning your existing synchronous code will still be functional. In fact, you are free to mix async and sync handlers and filters as much as you want. Pyrogram will still work concurrently and efficiently regardless of what you choose.

We expect that most projects will migrate to asynchronous handlers and filters for long-running applications such as event-driven bots in order to take advantage of a considerable speed increase. Batch applications without user interactions can still be written using synchronous calls to keep code more concise, but it is entirely your choice.

You can read more about Pyrogram's async support in the documentation:

Notable Changes

  • Since Pyrogram is now async natively, all the branches dedicated to the old async variant will be deleted soon, namely asyncio and asyncio-dev. To add Pyrogram in your requirements list, you can now simply use pyrogram instead of a URL.
  • The develop branch will also be removed in favor of the default master branch to keep branching clean. This is due to the fact that the master branch was never found to be of any real use except for keeping track of the latest published release (something that can be done with git tags).
  • Python 3.5 (EOL in less than three weeks) is no longer supported and you need to upgrade to at least Python 3.6.
  • Pyrogram's TL compiler now generates better code: the types used across the Telegram raw API are now 100% hinted allowing for excellent IDE support (auto-completion, warnings in case of wrong type usages, ...).
  • Pyrogram types, filters, handlers and emoji have been moved to their dedicated packages/modules:
    • The Filters and Emoji classes are now turned into modules. Import them this way:
      from pyrogram import filters, emoji
      instead of the old way:
      from pyrogram import Filters, Emoji
      
    • Pyrogram types and handlers now live in separate packages. Import them this way:
      from pyrogram.types import Message, User, ...
      from pyrogram.handlers import MessageHandler, ...
      instead of the old way:
      from pyrogram import Message, User, MessageHandler
      
  • idle() is now a function you can import from the main package and can be used right away:
    from pyrogram import idle
    ...
    idle()
    ...
  • The package holding the Telegram API raw methods and types has been renamed to a more suitable name. Import it this way:
    from pyrogram.raw import types, functions
    instead of the old way:
    from pyrogram.api import types, functions
    
  • Filter callbacks now take three arguments (self, client, update) instead of two (self, update). Your functions will therefore need to be defined like this:
    lambda flt, client, update: ...
    or:
    def filter_callback(flt, client, update):
        ...
    or (async):
    async def filter_callback(flt, client, update):
        ...

Miscellaneous

  • Pyrogram now uses a synced internal clock (synced with Telegram's server) that's independent of the local system's clock.
  • Heavy crypto parts will be executed in a pool of threads for big enough chunks of data. This will prevent the async event loop from blocking for too much time while allowing encryption & decryption tasks running in parallel thanks to TgCrypto's ability to leverage multiple CPU cores.
  • Examples previously found in GitHub are now accessible at https://docs.pyrogram.org/start/examples.
  • getpass is brought back, allowing to input your password without echoing it when you log-in with your account.
  • A warning message saying "do not edit - changes are lost" has been put inside each of the automatically generated Python files to warn curious developers about the possibility of losing changes to those files in case of re-compilations.
  • Implemented short-circuit evaluation for filters to avoid useless checks in and and or operations.
  • Added support for compiled patterns in filters.regex (contributed by @CyanBook in #468).
  • Updated send_* methods to accept pathlib objects (contributed by @CyanBook in $458).
  • Async filters are partly contributed by @HasibulKabir in #437, extended later on to work in an executor.
  • Added filters.all to filter all updates, useful as default filter to be combined with other optional filters (contributed bu @Princic-1837592 in #464).
Assets 2

@delivrance delivrance released this Jul 29, 2020

New Features & Enhancements

  • Updated the API schema to Layer 116.
  • Added support for uploads up to 2000 MiB in size to both user and bot identities.
  • Added support for in-memory uploads. You can now pass a BytesIO object when uploading a file that lives in-memory; make sure to set the object's .name attribute to a file name before using it, e.g.: b = BytesIO(...); b.name = "filename.zip" (contributed by @OctoNezd in #261).
  • Added support for profile videos. Pass a video file to set_profile_photo or set_chat_photo to update your profile picture using a video.
  • Added an automatic sleep mechanism for flood wait exceptions. Use Client's sleep_threshold parameter to set a sleep threshold for flood wait exceptions happening globally in a client instance, below which any request that raises a flood wait will be automatically invoked again after sleeping for the required amount of time. Flood wait exceptions requiring higher waiting times will be raised.
  • Added linked_chat to Chat objects. Useful to get the the linked discussion group (in case of channels) or the linked channel (in case of supergroups).
  • Added support for joining linked chats with the Chat.join bound method.
  • Filters.regex has been granted superpowers and can now be applied to handlers that receive Message, CallbackQuery or InlineQuery (previously it was only working for Message updates). This made Filters.callback_data obsolete which has been removed.
  • Added support for basketball and football animation of the random dice. Choose between different animations (dice, darts, basketball, football) by specifying the emoji parameter in the method send_dice.
  • Added search_global method for searching messages globally from all of your chats.
  • CallbackQuery.answer optional arguments are now actually optional in code.
  • Added the session name in log lines (contributed by @CrisMystik in #401).
  • Added Filters.linked_channel to filter messages coming from the channel connected to the chat.
  • Added file_name to file-related functions (contributed by @demget in #308 and @saidgadjiev in #440).
  • Logs in DEBUG level will now show more relevant information about what is being sent and received.
  • Updated the Bot API diagram in the documentation (minor graphical issues).
  • No need to add via_bot from Bot API v4.9 because Pyrogram already has it since long time ago.
  • Added a Message.link attribute to obtain the message link in form of a URL (contributed by @ColinTheShark in #442).
  • Extended set_slow_mode to accept None as argument for disabling the slow mode.
  • Added parse_mode parameter to Client. Set your desired parse_mode when creating a client instance (contributed by @mendelmaleh in #443).
  • send_document will now send actual documents, even when uploading a video file.
  • Updated instructions for accessing test servers in tdesktop.
  • Minor fixes and cleanups (also contributed by @alissonlauffer in #439).

Bug Fixes

  • Fixed docs about update_profile (contributed by @CyanBook in #395).
  • Fixed an issue in which messages sent with entities at the end of the text would result in messages without entities.
  • Fixed some small typos in the documentation.

Breaking Changes

  • Filters.callback_data has been removed in favor of Filters.regex.
Assets 2

@delivrance delivrance released this May 2, 2020

Bug Fixes

  • Fixed plugins not being properly unloaded when the exclude directive was used.
  • Fixed objects not being properly printed due to missing re.Match in Python <=3.6.
  • Fixed update_profile missing from docs and from Client.
Assets 2

@delivrance delivrance released this Apr 30, 2020

New Features and Enhancements

  • API schema updated to Layer 112.
  • Added a copy button to documentation snippets for easy copy pasting. Thanks to @ColinTheShark for this.
  • Added more Chat bound methods: get_member(), get_members(), iter_members and add_members (contributed by @rsktg in #383).
  • Added is_creator field to the Chat object.
  • A new block parameter has been added to stop(), restart() to allow calling them in a non-blocking way. Useful, with block=False, inside update handlers in order not to cause a deadlock.
  • Added a .bind() method to all Pyrogram types. Useful to re-enable bound-methods after deserialization by binding the client instance to the object.
  • Added a FAQ about why stop, restart, add/remove_handler could make the code hang if used improperly.
  • Added set_slow_mode() method.
  • Added update_profile() method (contributed by @kalmengr in #277).
  • Added support to quiz, public voting and multiple answers polls.
  • Added support for Telegram's Dice and Dart: added Dice and send_dice().
  • Added support for extended chat permissions for a finer control.
  • When no_updates=True Pyrogram will not spawn any unnecessary thread anymore.
  • Added FAQs about file_ref values, webhooks, flood limits and sqlite3.OperationalError.
  • Added support for ttl_seconds in Photo and Video objects. Useful for secret photos.
  • Added support for chosen inline results: added ChosenInlineResult type and an handler for listening to such update, on_chosen_inline_result().
  • Added support for scheduled forward messages.

Bug Fixes

  • Fixed an error causing delete_profile_photos() to fail.
  • Fixed group, channel and supergroup ChatPhoto downloads.
  • Fixed an issue causing Chat.restrict_member to fail.
  • Fixed plugins not being correctly reloaded from disk after a restart.
  • Fixed stop_poll (contributed by @trenoduro in #339).
  • Fixed error messages not being properly shown in case no_update=True.
  • Fixed set_administrator_title not properly setting permissions when changing a member's title.
  • Fixed editing media not working due to missing file references.
  • Fixed object decoder breaking on re.Match objects.
  • Fixed message entities being kept unparsed for private messages.

Breaking Changes

  • Dropped the [fast] setup directive. Now tgcrypto needs to be added as a separate dependency.
Assets 2

@delivrance delivrance released this Sep 25, 2019

New Features and Enhancements

  • Starting this version, support for Python 3.4 (EOL since March 16, 2019) has been dropped. The minimum requirement is now Python 3.5.3, but we suggest always using the latest Python version available, if possible.

  • The Telegram API schema has been updated to Layer 105.

  • Added support for scheduled messages. All applicable methods (send_message, send_photo, …) have now a schedule_date parameter used to schedule messages to be sent in a date in the future. Two filters have been added as well: Filters.scheduled, to filter outgoing messages that are scheduled and Filters.from_scheduled to filter messages that are sent automatically from the Telegram scheduler.

  • Added the attribute title (rank) to ChatMember objects and the method set_administrator_title().

  • The start() method has been finally decomposed into many reusable methods: connect(), disconnect(), initialize(), terminate(), send_code(), resend_code(), sign_in(), sign_up(), get_password_hint(), check_password(), send_recovery_code(), recover_password() and accept_terms_of_service(). You can use these methods individually to customize the authorization/registration flow much more easily.

  • You can now log-in with a bot token using the terminal prompt. Just paste a bot token and let Pyrogram authorize the bot automatically; once the session is created you don't need to keep the bot token around anymore.

  • Added log_out() method. Use it to log out your account from Telegram and delete the *.session file.

  • All available Pyrogram API methods in the documentation are now coupled with examples to give you an idea of how they are used.

  • Added WebPage type for web page previews. The web_page attribute of a Message will now point to a WebPage object instead of a boolean (contributed by @mendelmaleh in #268).

  • Added bound methods (contributed by @kalmengr in #274, #275, 278 and #279):

  • Removed get_user_dc() method. The user DC is now stored as a User attribute dc_id.

  • Added "md" to the possible parse modes for Markdown style.

  • Removed UserStatus type. A new status attribute has been added to User objects among with last_online_date and next_offline_date. This will make it easier to check for a user status by comparing user.status to strings such as "online", "offline", "last_week", …

  • The text parser will now log warnings instead of raising exceptions in case of unclosed tags.

  • Added set_parse_mode() method to set a global parse mode (client instance-wide). This is useful to save you from setting the parse mode on every method call, in case you want to use something else than the default.

  • send_media_group() is now able to send media from URLs.

  • Added new methods: add_chat_members(), create_group(), create_channel(), create_supergroup(), delete_channel() and delete_supergroup().

  • Added is_gallery parameter to to answer_inline_query() and InlineQuery.answer().

  • Added new inline query result types: InlineQueryResultPhoto and InlineQueryResultAnimation.

  • The command filter has been reworked to allow multiple words arguments inside quotes. For example: /start "this is one argument" will produce this Message.command list: ["start", "this is one argument"] (contributed by @mendelmaleh in #292). The prefix parameter has been renamed to prefixes for consistency with the other parameters names.

  • Added a new section to docs: scheduling (contributed by @MrNaif2018 in #283).

  • Added support for bot_token inside config.ini file (contributed by @trenoduro in #296).

  • Added a better support for unparsing nested entities (both for HTML and Markdown) (contributed by @Midblyte in #297).

  • Added Chat.export_invite_link() bound method (contributed by @ColinTheShark in #300) and get_common_chats() method (contributed by @ColinTheShark in #303).

  • Removed __slots__ from all Pyrogram types. They were pretty annoying to maintain and were giving little to no benefit.

  • Added is_animated field to Sticker.

  • Removed send_animated_sticker() in favour of send_sticker(), which is able to send both static and animated stickers.

  • Renamed restrict_chat to set_chat_permissions().

  • Moved all can_* permissions back to the ChatMember object.

  • Updated restrict_chat_member() to accept a single ChatPermissions argument.

  • Added Chat.description field to basic chats.

  • Added FAQ about "database is locked" error.

  • Added smarter auth import to deal with race conditions by multiple sessions: The time window in which export+import executes was narrowed down and a retry mechanism (up to three times) was added as well.

  • Removed the mention in the documentation of python-dev dependency for Termux when installing TgCrypto (contributed by @alissonlauffer in #301).

  • Added missing members_count attribute in Chat objects.

  • Added get_nearby_chats() method to get the nearby chats given a location expressed in latitude and longitude coordinates.

  • Added new Restriction object and made User and Chat object use it. The User and Chat restriction_reason has been renamed to restrictions and its type is now a List of Restriction objects instead of just a plain string.

Bug Fixes

  • Fixed RPCError raising an error by itself because of non-optional arguments.
  • Fixed Filters.private not filtering bot chat types (which are a kind of private chat).
  • Fixed forwarded copies having "None" as caption in case of no caption at all.
  • Fixed Message.text and Message.caption messing up in case of web page previews.
  • Fixed dispatcher raising exceptions in case filter checks failed (contributed by @mendelmaleh in #293).
  • Fixed Message.click() not working because of wrong default arguments.
  • Fixed VACUUM failing in Python 3.6.0 (exactly this version).

Breaking Changes

  • Removed support for callback functions for Client arguments like phone_number, phone_code, password, … in favour of a simpler and sequential authorization flow.

  • Reworked idle(): the method is now static and will only do what it is supposed to do, idling; it won't stop the client anymore when idling ends. For this reason, you now have to call app.stop() yourself after it.

  • The upload/download progress callback will not accept the client parameter anymore because is often redundant. This means that only (current, total) arguments will be passed by default. If you need a client reference, you can pass it via progress_args anytime. Most likely you want to pass a Message instance, instead, and use bound methods to make API calls in a more convenient way.

  • All Photo-like file id formats have changed to be compatible with the ones offered by the Bot API. This, unfortunately, means that all previous file ids can't be used anymore.

  • To correctly download, re-send, edit or forward as copy a media message, you must now pass a valid and up to date file_ref (file reference) you can get from a media object (Photo, Audio, Document, …). The inevitable downside (because this is how Telegram wants it to work now) is that once a file reference expires (usually after 24h, but could happen anytime) you have to manually fetch the original message again with get_messages and the context (a pair of chat_id + message_id) in order to get a refreshed file reference. A new file_ref parameter has been added to all methods dealing with media messages as well (send_photo, *_audio, *_document, …).

Assets 2

@delivrance delivrance released this Jul 1, 2019

New Features and Enhancements

  • API schema updated to Layer 102.

  • TgCrypto updated to v1.2.0.

  • Goodbye JSON-based session files, you served very well, but is now time for Storage Engines. This version brings two built-in implementations based on SQLite: File Storage and Memory Storage. Extra storage engines for different storage options (such as Redis, MySQL, MongoDB, ...) can be easily implemented as well. (proposal by @bakatrouble, which provided an implementation in #220 that got refactored).

  • Added export_session_string() method to export a session string. Session strings are useful when you want to run authorized Pyrogram clients completely in-memory on platforms like Heroku, where their ephemeral filesystems makes it much harder for a file-based storage engine to properly work as intended.

  • Text Formatting re-done from scratch. You can now style message texts and captions using extra styles like underline and strikethrough styles, in both Markdown and HTML. You can nest and combine multiple styles together on the same text too, such as in this example (bold, italic and strikethrough text) and also disable the parser completely by passing None as argument to the parse_mode parameter.

  • Added archive_chats() and unarchive_chats() methods to archive and unarchive your chats.

  • Added archive() and unarchive() bound methods to User and Chat types as convenience shortcuts for archive_chats() and unarchive_chats().

  • Added new methods to edit messages sent by inline bots: edit_inline_text(), edit_inline_caption(), edit_inline_media() and edit_inline_reply_markup(). The reason behind having 4+4 methods for editing normal messages and messages sent by inline bots is because of Telegram requiring a special inline_message_id that is mutually exclusive with the usual pair of chat_id+message_id.

  • Added new CallbackQuery bound-methods for editing messages: edit_message_text(), edit_message_caption(), edit_message_media() and edit_message_reply_markup().

  • Added friendly methods to block and unblock users: block_user() and unblock_user() (contributed by @ColinTheShark in #256).

  • Added new Chat bound-methods: set_title(), set_description(), set_photo(), kick_member(), unban_member(), restrict_member() and promote_member() (contributed by @mendelmaleh in #260).

  • Added some new FAQs about: DC migration, DC IP addresses, library stability and reliability.

  • Added a bunch of new errors: FOLDER_DEAC_AUTOFIX_ALL, FOLDER_ID_INVALID, MEGAGROUP_PREHISTORY_HIDDEN, CHAT_LINK_EXISTS, LINK_NOT_MODIFIED, BROADCAST_ID_INVALID and MEGAGROUP_ID_INVALID, START_PARAM_INVALID, MSGID_DECREASE_RETRY.

  • Removed Messages, ChatMembers, Dialogs, ProfilePhotos and GameHighScores types. These types were just annoying wrappers around bare lists and removing them means that now you get a simple list of objects:

    • Messages → List of Message objects.
    • ChatMembers → List of ChatMember objects.
    • Dialogs → List of Dialog objects.
    • ProfilePhotos → List of Photo objects.
    • GameHighScores → List of GameHighScore objects.

    Dealing with methods which returned such types has also become easier. Instead of doing the following:

    history = app.get_history("pyrogramchat")
    print(history.messages[0])

    you can omit .messages because the returned type is a simple list:

    history = app.get_history("pyrogramchat")
    print(history[0])

    To get the total count of items each old type contained, you have to use the respective methods: get_history_count(), get_chat_members_count(), get_dialogs_count(), get_profile_photos_count().

  • Unknown errors with known error codes are now raised by their category error instead of 520 UnknownError. For example, an unknown error that has the known error code 400 will be raised as BadRequest. Totally unknown errors (with both unknown message and error code) will still be raised as UnknownError.

  • Error messages now contain information about which raw method caused the RPC error. For example: [400 MESSAGE_EMPTY]: The message sent is empty (caused by "messages.SendMessage").

Bug Fixes

  • Fixed get_profile_photos() method not working when passing me or self as argument.

  • Fixed plugins not getting reloaded properly when restarting a client.

  • Fixed download_media() ignoring the file_name argument which also lead to files being saved with random names generated by the framework.

  • Fixed script executions not working outside the current directory (addressed #41).

  • Fixed texts being sliced incorrectly when trying to use the offsets and lengths from message entities.

  • Fixed delete_profile_photos() not working since that last update (addressed #259).

  • Fixed objects failing to print in case there's no __slots__ attribute.

Breaking Changes

  • ChatMembers, Dialogs, ProfilePhotos, Messages and GameHighScores types are now gone and replaced with simple lists of objects (as explained in the section above).

  • The name argument of Filters.create() is now optional and moved behind. The simplest custom filter you can create will now look like this: flt = Filters.create(lambda _, m: ...).

Assets 2

@delivrance delivrance released this Jun 7, 2019

New Features

  • API Schema updated to Layer 100.
  • Pyrogram is now able to handle message floods without slowing down. While there's still a lot of room for extra performance, thanks to the community and in particular to @Talocan who helped with load tests, I was able to fix this major bottleneck which would have slowed down the library in case of huge amount of messages received - we are talking about 50-80 messages per second, which is quite a lot for a single user/bot to handle.
  • Added get_user_dc() to get a user's assigned DC (Data Center).
  • Added read_history() to read (marking as read, double-tick) a chat history.
  • Added Filters.callback_data to filter callback query data (contributed by @ColinTheShark in #248 ).
  • Added send_animated_sticker() to send the new Telegram animated stickers in .tgs format. Note: this is still an experimental feature, not even all official clients properly support animated stickers and Telegram has not announced anything yet about this new feature.
  • Added iter_profile_photos() to iterate over a user or a chat profile photos sequentially.
  • Added a new section in the documentation: Debugging and Release Notes.
  • Added new FAQs in the documentation.
  • Added easter eggs.

Enhancements

  • Added the unsave parameter to send_animation(). Pass True in order to remove the GIF animation from your own collection (the server automatically adds them).
  • Bare lists, such as [1, 2, 3, 4, 5] when coming from the Telegram raw API are now printed nicely.
  • The PhotoSize type has been replaced by Thumbnail, a much more interesting and useful name.
  • The Photo type has been revamped: forget message.photo.sizes[-1].file_id, you can now simply use message.photo.file_id to get the highest quality available, all the other sizes are kept as a list of thumbnails in the thumbs attribute.
  • All applicable media now have a thumbs attribute to store all the available thumbnails (there can be more than one, sorted by ascending size).
  • When printing Pyrogram objects, phone numbers are now hidden and each digit replaced with a star *. E.g. 391234567890************. Date attributes are shown as human-readable dates instead of a unix timestamps. E.g. 15597426282019-06-05 15:50:28. Note this is just a visual modification, when accessing the inner attributes, you will still get the same values (full number, unix timestamp).
  • get_profile_photos() and get_profile_photos_count() now work for both users and chats.
  • Chat and User types have new attributes:
    • is_verified
    • is_restricted
    • is_scam
    • is_support (user only).

Bug Fixes

Breaking Changes

Assets 2

@delivrance delivrance released this May 25, 2019

This version features a massive overhaul of the documentation structure and a shiny new domain name: https://pyrogram.org. After well over a week spent working solely on the documentation website, here's what's new:

That's all about the documentation, for now. I hope you enjoy it! Let's now go ahead with listing the new features this version brings in the library itself:

New Features

Enhancements

  • get_chat() method is now able to fetch the pinned message in your own chat (saved messages).
  • Increased media thumbnail size from 90px to 320px side length.
  • Added is_member attribute to the ChatMember type to check wether a restricted user is still a member of a chat.
  • Added back the automatic mime type detection for new uploads.
  • Sending and receiving callback_data (with inline buttons and callback query respectively) has gained back support for strings. If you pass strings for which you are 100% sure they will be valid UTF-8 texts, you can rely on the library reporting back string types, otherwise you'll get a bytes type. This is due to how Telegram handles callback queries data (only bytes allowed) and it's a matter of convenience to allow strings as well.
  • Added supports_streaming attribute to the Video type.
  • Hint about which client is loading which plugins folder when you start them.
  • Added a timeout parameter to Message.click()
  • Allowed Message.click() to be called without any argument for clicking the first button.

Bug Fixes

  • Method delete_messages() and Message.delete() will now return False in case they fail to delete (they used to always return True due to how Telegram handles this method; the server doesn't raise any error).
  • get_messages() is now able to get more than one reply using the replies parameter. Up to unlimited replies.

Breaking Changes

  • Method close_poll() was renamed to stop_poll().
  • Attribute forward_from_name of Message was renamed to forward_sender_name.
  • Poll ids are now strings and not integers.
  • ParseMode module was removed. It was pretty much useless, better just use "markdown" and "html" string literals.
  • ChatAction module was removed too, same reason of ParseMode.
  • Removed get_chat_preview() method, get_chat() will take care of both Chat and ChatPreview objects.
Assets 2