Hack limits

This commit is contained in:
vas3k
2020-02-26 10:34:17 +01:00
parent a5dbd896d0
commit 604ccd0444
2 changed files with 5 additions and 2 deletions

View File

@@ -6,8 +6,10 @@ from parsing.telegram.parsers import Parser, parse_channel
from parsing.telegram.models import MessageType
import asyncio
DEFAULT_LIMIT = 30
def get_channel(channel_id, *, types=None, limit=10):
def get_channel(channel_id, *, types=None, limit=DEFAULT_LIMIT):
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
with TelegramClient(
@@ -29,7 +31,7 @@ def get_channel(channel_id, *, types=None, limit=10):
return channel
def get_channel_messages(client, channel, *, types=None, limit=10):
def get_channel_messages(client, channel, *, types=None, limit=DEFAULT_LIMIT):
def get_messages_indexes(messages, grouped_id, type=None, inverse=False):
type_predicate = lambda m: m != type if inverse else m == type
indexes = []

View File

@@ -14,6 +14,7 @@ class TelegramChannelFeed(Feed):
only = str(request.GET.get("only") or "")
if only:
only = [item.strip() for item in only.split(",")]
limit = 100 # dirty hack: artificially increase the limit to get more filtered messages
try:
return get_channel(channel, types=only, limit=limit)