Compare commits

..

3 Commits

3 changed files with 11 additions and 7 deletions

View File

@ -28,8 +28,10 @@ def create_task(session_id: int):
types = list(filter(lambda item: item in ('parse', 'add', 'message'), info.keys()))
if len(types) > 0:
type = types[0]
if len(types) <= 0:
return "", 204
type = types[0]
task = Task(
name = info.get('task_name') or str(uuid.uuid4()),

View File

@ -3,7 +3,7 @@ import time
from celery import shared_task
import asyncio
from telethon.tl.types import UserStatusOnline, UserStatusOffline
from telethon.tl.types import UserStatusOnline, UserStatusOffline, UserStatusRecently
from app.models.user import User
from paper.parser import PaperParser
@ -55,14 +55,16 @@ def parse_users_task(self, task_id: int):
)
for user in users:
if not user.username and user.bot:
if not user.username or user.bot:
continue
is_active = False
if isinstance(user.status, UserStatusOffline):
is_active = user.status.was_online + datetime.timedelta(day=5) >= datetime.now()
was_online = user.status.was_online.replace(tzinfo=datetime.timezone.utc)
today = datetime.datetime.today().replace(tzinfo=datetime.timezone.utc)
is_active = was_online + datetime.timedelta(days=5) >= today
if isinstance(user.status, UserStatusOnline):
if isinstance(user.status, UserStatusOnline) or isinstance(user.status, UserStatusRecently):
is_active = True
if not is_active:

View File

@ -38,7 +38,7 @@
<section class="tab-pane fade" id="actions-add-section">
<div class="form-floating">
<input type="text" name="url" name="add" class="form-control" id="group-to-input"
<input type="text" name="add" class="form-control" id="group-to-input"
placeholder="Группа для добавлнеия">
<label for="group-to-input">Группа для добавления</label>
</div>