Skip to content

Commit

Permalink
Update to latest commits (Sourcery refactored) (#19)
Browse files Browse the repository at this point in the history
* Change bug report template to an issue form

Lifted from Tachiyomi and adapted for Telethon.

See: https://github.com/tachiyomiorg/tachiyomi/blob/master/.github/ISSUE_TEMPLATE/report_issue.yml

* Change feature request template to an issue form

* Add dedicated form for documentation issues

* Update some fields in the GH issue template

* Fix comment_to for a group of messages (LonamiWebs#4120)

* Clarify OS field in bug report template

* Handle CancelledError inside mtprotosender recv loop

* Add missing formatting arg in logging call

Noticed in LonamiWebs#4123.

* Document more RPC errors (LonamiWebs#4127)

* Support most usernames in VALID_USERNAME_RE

See LonamiWebs#4128.

* Fix lack of support for anon channel restrictions (LonamiWebs#4130)

* Improve error message when trying to delete inline messages

Closes LonamiWebs#4129.

* Change html.unparse logic to mimic markdown's

It was overcomplicated and had some subtle bugs.
Closes LonamiWebs#4133.

* Update to layer 160

* Fix reply_to can be optional

* Fix _get_thumb failed when document had no thumbs

* Remove client-side checks when editing permissions

The server should instead fail with proper RPC errors,
as the rules could change any time (and the local checks
get out of date).

* Handle sqlite3.OperationalError in update loop

* Handle FloodWaitError in update loop

Likely temporary server issues, since getDifference should
realistically not fail with flood waits. In any case,
stopping early until the problem is resolved is the correct
approach.

* Don't attempt thumb download if there is no thumb

* Disable blank issues in GitHub (LonamiWebs#4157)

* Bump to v1.29.0

* Fix handling of UpdateShortSentMessage

* Improve image compression heuristics and algorithm used (LonamiWebs#4158)

* Fix reply_to when sending albums

* Sort tlobjects before generating their listing (LonamiWebs#4163)

* Don't treat asyncio.IncompleteReadError as unhandled

The library will behave the same, but the log severity is lowered.

* Except all types of timeout error

Closes LonamiWebs#4172.

* Return marked ID from MemorySession.get_entity_rows_by_id (LonamiWebs#4177)

Otherwise the unpacking done later won't work.

* Fix `is_inline` check for `KeyboardButtonWebView` (LonamiWebs#4183)

* Make MessageBox trace logs more useful

* Fix getting_diff_for with empty set was being spammed

Because the above check used >= but the inner check >.

* Further improve MessageBox trace logging

* Only update seq if pts changed

This solves UpdateChatParticipant being missed after UpdateChat,
which seems to reliable occur when a bot is in a Chat that gets
deleted.

* Change apply_deadlines_reset micro-optimization

No need for buffer reuse in Python. It simply complicates the code.
And even then it was not as optimal as it could.

* Update to layer 161

Closes LonamiWebs#4184.

* Fix incorrect param type in apply_channel_difference (LonamiWebs#4185)

* Fix date empty (LonamiWebs#4191)

* Remove client-side check in message.edit (LonamiWebs#4195)

Fixes LonamiWebs#4193.

* Update to layer 162

* Bump to v1.30

* Fix generator for pypy (LonamiWebs#4198)

* Fix invalid date type in UpdateShort

* Fix date empty when getting difference

* Fixed sorting of markup entities with the same offsets (LonamiWebs#4201)

* Remove uses of imghdr

It's deprecated. Closes LonamiWebs#4207.

* Update to layer 164

* Update to layer 165

* Update to v1.31

* Fix file name could be lost when uploading files

Leading to invalid extension when sending photos.

* Update to layer 166

* Fix init of custom Draft after layer update

* Bump to v1.32

* Add PR template mentioning v1 is feature-frozen

Should prevent efforts like LonamiWebs#4244 going to waste in the future.

* Force filename with JPG extension after resizing

Old name does not matter, since we just encoded it as JPEG

* Retry on TimedOutError (LonamiWebs#4255)

* Conditional webbrowser import (LonamiWebs#4261)

* Update to layer 167

* Bump to v1.33

* Prioritise closing tags when sorting tags

* Fix ordering of nested entities

* Bump to v1.33.1

* 'Refactored by Sourcery'

---------

Co-authored-by: novenary <streetwalkermc@gmail.com>
Co-authored-by: Lonami <totufals@hotmail.com>
Co-authored-by: iamilya <greznev@me.com>
Co-authored-by: Devesh Pal <newdev0@outlook.com>
Co-authored-by: rozha <il.novikov@gmail.com>
Co-authored-by: novenary <1155030+9ary@users.noreply.github.com>
Co-authored-by: Nick80835 <nick80835@gmail.com>
Co-authored-by: Bernhard M. Wiedemann <githubbmwprimary@lsmod.de>
Co-authored-by: Kacnep89 <76146578+Kacnep89@users.noreply.github.com>
Co-authored-by: misuzu <neironyan@gmail.com>
Co-authored-by: Shubham Kumar <kshubham506@gmail.com>
Co-authored-by: Non <thenonproton@protonmail.com>
Co-authored-by: Dingyuan Wang <abcdoyle888@gmail.com>
Co-authored-by: Alexander Goryushkin <43167451+alexgoryushkin@users.noreply.github.com>
Co-authored-by: mario-ttide <109175699+mario-ttide@users.noreply.github.com>
Co-authored-by: Balázs Triszka <info@balika011.hu>
Co-authored-by: udf <tabhooked@gmail.com>
Co-authored-by: Sourcery AI <>
  • Loading branch information
18 people committed Dec 11, 2023
1 parent 5889da2 commit f009a0b
Show file tree
Hide file tree
Showing 29 changed files with 654 additions and 259 deletions.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/config.yml
@@ -1,3 +1,4 @@
blank_issues_enabled: false
contact_links:
- name: Ask questions in StackOverflow
url: https://stackoverflow.com/questions/ask?tags=telethon
Expand Down
5 changes: 5 additions & 0 deletions .github/pull_request_template.md
@@ -0,0 +1,5 @@
<!--
Thanks for the PR! Please keep in mind that v1 is *feature frozen*.
New features very likely won't be merged, although fixes can be sent.
All new development should happen in v2. Thanks!
-->
149 changes: 149 additions & 0 deletions readthedocs/misc/changelog.rst
Expand Up @@ -13,6 +13,155 @@ it can take advantage of new goodies!

.. contents:: List of All Versions

New layer (v1.33)
=================

+------------------------+
| Scheme layer used: 167 |
+------------------------+

`View new and changed raw API methods <https://diff.telethon.dev/?from=166&to=167>`__.

Enhancements
~~~~~~~~~~~~

* ``webbrowser`` is now imported conditionally, to support niche environments.
* Library should now retry on the suddenly-common ``TimedOutError``.

Bug fixes
~~~~~~~~~

* Sending photos which were automatically resized should work again (included in the v1.32 series).


New layer (v1.32)
=================

+------------------------+
| Scheme layer used: 166 |
+------------------------+

`View new and changed raw API methods <https://diff.telethon.dev/?from=165&to=166>`__.

This enables you to use custom languages in preformatted blocks using HTML:

.. code-block:: html

<pre>
<code class='language-python'>from telethon import TelegramClient</code>
</pre>

Note that Telethon v1's markdown is a custom format and won't support language tags.
If you want to set a custom language, you have to use HTML or a custom formatter.


Dropped imghdr support (v1.31)
==============================

+------------------------+
| Scheme layer used: 165 |
+------------------------+

This release contains a breaking change in preparation for Python 3.12.
If you were sending photos from in-memory ``bytes`` or ``BytesIO`` containing images,
you should now use ``BytesIO`` and set the ``.name`` property to a dummy name.
This will allow Telethon to detect the correct extension (and file type).

.. code-block:: python
# before
image_data = b'...'
client.send_file(chat, image_data)
# after
from io import BytesIO
image_data = BytesIO(b'...')
image_data.name = 'a.jpg' # any name, only the extension matters
client.send_file(chat, image_data)
Bug fixes
~~~~~~~~~

* Code generation wasn't working under PyPy.
* Obtaining markdown or HTML from message text could produce unexpected results sometimes.
* Other fixes for bugs from the previous version, which were already fixed in patch versions.

Breaking Changes
~~~~~~~~~~~~~~~~

* ``imghdr`` is deprecated in newer Python versions, so Telethon no longer uses it.
This means there might be some cases where Telethon fails to infer the file extension for buffers containing images.
If you were relying on this, add ``.name = 'a.jpg'`` (or other extension) to the ``BytesIO`` buffers you upload.

Layer bump and small changes (v1.30)
====================================

+------------------------+
| Scheme layer used: 162 |
+------------------------+

Some of the bug fixes were already present in patch versions of ``v1.29``, but
the new layer necessitated a minor bump.

Enhancements
~~~~~~~~~~~~

* Removed client-side checks for editing messages.
This only affects ``Message.edit``, as ``client.edit_message`` already had
no checks.
* Library should not understand more server-side errors during update handling
which should reduce crashes.
* Client-side image compression should behave better now.

Bug fixes
~~~~~~~~~

* Some updates such as ``UpdateChatParticipant`` were being missed due to the
order in which Telegram sent them. The library now more carefully checks for
the sequence and pts contained in them to avoid dropping them.
* Fixed ``is_inline`` check for :tl:`KeyboardButtonWebView`.
* Fixed some issues getting entity from cache by ID.
* ``reply_to`` should now work when sending albums.


More bug fixing (v1.29)
=======================

+------------------------+
| Scheme layer used: 160 |
+------------------------+

This layer introduces the necessary raw API methods to work with stories.

The library is aiming to be "feature-frozen" for as long as v1 is active,
so friendly client methods are not implemented, but example code to use
stories can be found in the GitHub wiki of the project.

Enhancements
~~~~~~~~~~~~

* Removed client-side checks for methods dealing with chat permissions.
In particular, this means you can now ban channels.
* Improved some error messages and added new classes for more RPC errors.
* The client-side check for valid usernames has been loosened, so that
very short premium usernames are no longer considered invalid.

Bug fixes
~~~~~~~~~

* Attempting to download a thumbnail from documnets without one would fail,
rather than do nothing (since nothing can be downloaded if there is no thumb).
* More errors are caught in the update handling loop.
* HTML ``.text`` should now "unparse" any message contents correctly.
* Fixed some problems related to logging.
* ``comment_to`` should now work as expected with albums.
* ``asyncio.CancelledError`` should now correctly propagate from the update loop.
* Removed some absolute imports in favour of relative imports.
* ``UserUpdate.last_seen`` should now behave correctly.
* Fixed a rare ``ValueError`` during ``connect`` if the session cache was bad.


New Layer and housekeeping (v1.28)
==================================

Expand Down
3 changes: 2 additions & 1 deletion setup.py
Expand Up @@ -180,8 +180,9 @@ def main(argv):
# Try importing the telethon module to assert it has no errors
try:
import telethon
except:
except Exception as e:
print('Packaging for PyPi aborted, importing the module failed.')
print(e)
return

remove_dirs = ['__pycache__', 'build', 'dist', 'Telethon.egg-info']
Expand Down

0 comments on commit f009a0b

Please sign in to comment.