Support deleting more than 100 messages at once

This commit is contained in:
Lonami Exo
2018-06-05 21:27:49 +02:00
parent 30ad06f29a
commit ed5c44a260
2 changed files with 21 additions and 10 deletions

View File

@@ -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`,