delivrance
released this
New Features & Additions
- API schema updated to Layer 126.
- Added a friendly interface for getting chat Event Logs (also known as recent admin actions):
- Added the method get_chat_event_log to get the actions taken by chat members and administrators in the last 48h.
- Added the types ChatEvent and ChatEventFilter.
- Added support for the improved Invite Links (create, edit, revoke links; see admins' links and who joined using your links).
- Added the methods:
- get_chat_invite_link - Get detailed information about a chat invite link.
- create_chat_invite_link - Create an additional invite link for a chat.
- edit_chat_invite_link - Edit a non-primary invite link.
- revoke_chat_invite_link - Revoke a previously created invite link.
- delete_chat_invite_link - Delete an already revoked invite link.
- get_chat_invite_link_members - Get the members who joined the chat with the invite link.
- get_chat_invite_link_members_count - Get the count of the members who joined the chat with the invite link.
- get_chat_admin_invite_links - Get the invite links created by an administrator in a chat.
- get_chat_admin_invite_links_count - Get the count of the invite links created by an administrator in a chat.
- get_chat_admins_with_invite_links - Get the list of the administrators that have exported invite links in a chat.
- delete_chat_admin_invite_links - Delete all revoked invite links of an administrator.
- Added the types ChatInviteLink and ChatAdminWithInviteLinks.
- Added the methods:
- Added support for Voice Chat service messages and information:
- Added the type VoiceChatStarted, the field
voice_chat_startedto the class Message and the filter voice_chat_started. - Added the type VoiceChatEnded, the field
voice_chat_endedto the class Message and the filter voice_chat_ended. - Added the type VoiceChatMembersInvited, the field
voice_chat_members_invitedto the class Message and the filter voice_chat_members_invited. - Added the new administrator privilege
can_manage_voice_chatsto the class ChatMember and parametercan_manage_voice_chatsto the method promote_chat_member.
- Added the type VoiceChatStarted, the field
- Added support for Chat Member status changes via dedicated events:
- Added the new handler ChatMemberUpdatedHandler and its decorator on_chat_member_updated which will be used to listen for events represented by ChatMemberUpdated. The new event handler will listen for chat member status changes and will pass a
ChatMemberUpdatedobject with the information about the previous and the new chat member status.
- Added the new handler ChatMemberUpdatedHandler and its decorator on_chat_member_updated which will be used to listen for events represented by ChatMemberUpdated. The new event handler will listen for chat member status changes and will pass a
- Added the field
is_faketo both User and Chat classes. - Added the bound method Message.get_media_group.
- Added the new administrator privilege
can_manage_chatto the class ChatMember and parametercan_manage_chatto the method promote_chat_member. - Added add_contact for adding an existing Telegram user as contact, even without a phone number. Renamed
add_contactsto import_contacts. - Added support for user mentions inside inline query results.
- Added new information about voice calls.
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
released this
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_refparameter is now useless and has been removed from the API in favour of a singlefile_idparameter. Afile_unique_idparameter 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_chatattribute to Message objects. - Added support for anonymous chat members: added
is_anonymousattribute 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
bioattribute 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_secondssupport for send_video and Message.reply_video (contributed by @drizzt in #556).
Bugfixes & Enhancements
- Made
new_chat_photodownloadable (contributed by @GodSaveTheDoge #508). - Enhanced
filters.meto 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_dateparameter 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
awaitkeywords. - Fixed media captions being displayed as "None" for inline media results when no caption was passed.
- Reverted to
inputfor passwords and added thehide_passwordparameter to Client. - Added the
sleep_thresholdparameter to thesend()method. - Decreased the default sleep threshold from 60 to 10 seconds.
- Fixed some "invalid escape" warnings.
- Enabled passing
sleep_threshold=0to 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
TLObjectas super class for base types. - Added the attribute
dc_idto 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_documentargument 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_membersto "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
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
asyncioandasyncio-dev. To add Pyrogram in your requirements list, you can now simply usepyrograminstead of a URL. - The
developbranch will also be removed in favor of the defaultmasterbranch 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
FiltersandEmojiclasses are now turned into modules. Import them this way:instead of the old way:from pyrogram import filters, emoji
from pyrogram import Filters, Emoji - Pyrogram types and handlers now live in separate packages. Import them this way:
instead of the old way:
from pyrogram.types import Message, User, ... from pyrogram.handlers import MessageHandler, ...
from pyrogram import Message, User, MessageHandler
- The
- 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:
instead of the old way:
from pyrogram.raw import types, functions
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:
or:
lambda flt, client, update: ...
or (async):def filter_callback(flt, client, update): ...
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.
getpassis 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
andandoroperations. - 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.allto filter all updates, useful as default filter to be combined with other optional filters (contributed bu @Princic-1837592 in #464).
Assets
2
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
.nameattribute 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_thresholdparameter 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_chatto 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_dataobsolete 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_nameto file-related functions (contributed by @demget in #308 and @saidgadjiev in #440). - Logs in
DEBUGlevel 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_botfrom Bot API v4.9 because Pyrogram already has it since long time ago. - Added a
Message.linkattribute 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_modeparameter 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_datahas been removed in favor of Filters.regex.
Assets
2
Bug Fixes
- Fixed plugins not being properly unloaded when the
excludedirective was used. - Fixed objects not being properly printed due to missing
re.Matchin Python <=3.6. - Fixed update_profile missing from docs and from Client.
Assets
2
delivrance
released this
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_creatorfield to the Chat object. - A new
blockparameter has been added to stop(), restart() to allow calling them in a non-blocking way. Useful, withblock=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=TruePyrogram will not spawn any unnecessary thread anymore. - Added FAQs about file_ref values, webhooks, flood limits and sqlite3.OperationalError.
- Added support for
ttl_secondsin 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. Nowtgcryptoneeds to be added as a separate dependency.
Assets
2
delivrance
released this
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 aschedule_dateparameter 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 andFilters.from_scheduledto 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_pageattribute 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 attributedc_id. -
Added
"md"to the possible parse modes for Markdown style. -
Removed
UserStatustype. A newstatusattribute has been added to User objects among withlast_online_dateandnext_offline_date. This will make it easier to check for a user status by comparinguser.statusto 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_galleryparameter 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). Theprefixparameter has been renamed toprefixesfor 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_animatedfield to Sticker. -
Removed
send_animated_sticker()in favour of send_sticker(), which is able to send both static and animated stickers. -
Renamed
restrict_chatto set_chat_permissions(). -
Moved all
can_*permissions back to the ChatMember object. -
Updated restrict_chat_member() to accept a single ChatPermissions argument.
-
Added
Chat.descriptionfield 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-devdependency for Termux when installing TgCrypto (contributed by @alissonlauffer in #301). -
Added missing
members_countattribute 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_reasonhas been renamed torestrictionsand its type is now a List of Restriction objects instead of just a plain string.
Bug Fixes
- Fixed
RPCErrorraising an error by itself because of non-optional arguments. - Fixed
Filters.privatenot filteringbotchat types (which are a kind of private chat). - Fixed forwarded copies having "None" as caption in case of no caption at all.
- Fixed
Message.textandMessage.captionmessing 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
clientparameter 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 viaprogress_argsanytime. Most likely you want to pass aMessageinstance, 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 newfile_refparameter has been added to all methods dealing with media messages as well (send_photo, *_audio, *_document, …).
Assets
2
delivrance
released this
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 passingNoneas argument to the parse_mode parameter. -
Added archive_chats() and unarchive_chats() methods to archive and unarchive your chats.
-
Added
archive()andunarchive()bound methods to User and Chat types as convenience shortcuts forarchive_chats()andunarchive_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()andedit_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()andpromote_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_INVALIDandMEGAGROUP_ID_INVALID,START_PARAM_INVALID,MSGID_DECREASE_RETRY. -
Removed
Messages,ChatMembers,Dialogs,ProfilePhotosandGameHighScorestypes. 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
.messagesbecause 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 code400will be raised asBadRequest. Totally unknown errors (with both unknown message and error code) will still be raised asUnknownError. -
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
meorselfas argument. -
Fixed plugins not getting reloaded properly when restarting a client.
-
Fixed download_media() ignoring the
file_nameargument 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,MessagesandGameHighScorestypes are now gone and replaced with simple lists of objects (as explained in the section above). -
The
nameargument 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
released this
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
.tgsformat. 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
unsaveparameter 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
PhotoSizetype 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 usemessage.photo.file_idto get the highest quality available, all the other sizes are kept as a list of thumbnails in thethumbsattribute. - All applicable media now have a
thumbsattribute 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.1559742628→2019-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_verifiedis_restrictedis_scamis_support(user only).
Bug Fixes
- export_chat_invite_link() wasn't working on basic groups.
Breaking Changes
- Renamed
UserProfilePhotosto just ProfilePhotos for brevity, but also because such object can now store profile photos from both users and chats. - Due to internal server changes, the file_id format of all photo-like objects has changed. Types affected are Thumbnail, ChatPhoto and Photo.
- Renamed some methods:
delete_user_profile_photos()→ delete_profile_photos()get_user_profile_photos()→ get_profile_photos()set_user_profile_photo()→ set_profile_photo()get_user_profile_photos_count()→ get_profile_photos_count()
Assets
2
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:
- The documentation now lives at https://docs.pyrogram.org.
- New style touches to make the overall website design more pleasant to look at.
- New documentation sections: Introduction, Getting Started, API Reference, Topic Guides and Meta.
- A Quickstart page to get new Pyrogrammers start as fast as possible.
- Methods, Types and Bound Methods are kept in separate pages with lots of cross-references.
- New FAQ, Glossary and Powered-by pages.
- Lots of other additions and enhancements throughout existing pages to make them more detailed.
- And finally, a page dedicated to all people who'd like to show their appreciation for my work :)
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
- Added a PollHandler and an on_poll() decorator for handling Poll updates.
- Added get_history_count() method.
- Added get_dialogs_count() method.
- Added get_contacts_count() method.
- Added get_user_profile_photos_count() method.
- New
botchat type. We now have "private", "bot", "group", "supergroup" and "channel" Chat
types.
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_memberattribute 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_streamingattribute to the Video type. - Hint about which client is loading which plugins folder when you start them.
- Added a
timeoutparameter 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
Falsein 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
repliesparameter. Up to unlimited replies.
Breaking Changes
- Method
close_poll()was renamed to stop_poll(). - Attribute
forward_from_nameof Message was renamed toforward_sender_name. - Poll ids are now strings and not integers.
ParseModemodule was removed. It was pretty much useless, better just use "markdown" and "html" string literals.ChatActionmodule was removed too, same reason ofParseMode.- Removed
get_chat_preview()method, get_chat() will take care of both Chat and ChatPreview objects.