mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-05 03:22:29 +00:00
Support deleting more than 100 messages at once
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
Utilities for working with the Telegram API itself (such as handy methods
|
||||
to convert between an entity like an User, Chat, etc. into its Input version)
|
||||
"""
|
||||
import itertools
|
||||
import math
|
||||
import mimetypes
|
||||
import os
|
||||
@@ -56,6 +57,17 @@ class Default:
|
||||
"""
|
||||
|
||||
|
||||
def chunks(iterable, size=100):
|
||||
"""
|
||||
Turns the given iterable into chunks of the specified size,
|
||||
which is 100 by default since that's what Telegram uses the most.
|
||||
"""
|
||||
it = iter(iterable)
|
||||
size -= 1
|
||||
for head in it:
|
||||
yield itertools.chain([head], itertools.islice(it, size))
|
||||
|
||||
|
||||
def get_display_name(entity):
|
||||
"""
|
||||
Gets the display name for the given entity, if it's an :tl:`User`,
|
||||
|
Reference in New Issue
Block a user