filter users by activity
This commit is contained in:
parent
a752c2fa1f
commit
5520fe0204
|
@ -1,10 +1,11 @@
|
|||
import datetime
|
||||
import time
|
||||
|
||||
from celery import shared_task
|
||||
import asyncio
|
||||
from app.models.session import Session
|
||||
from app.models.user import User
|
||||
from telethon.tl.types import UserStatusOnline, UserStatusOffline
|
||||
|
||||
from app.models.user import User
|
||||
from paper.parser import PaperParser
|
||||
from app.models.task import Task
|
||||
from app.extensions import db
|
||||
|
@ -54,7 +55,17 @@ def parse_users_task(self, task_id: int):
|
|||
)
|
||||
|
||||
for user in users:
|
||||
if not user.username:
|
||||
if not user.username and user.bot:
|
||||
continue
|
||||
|
||||
is_active = False
|
||||
if isinstance(user.status, UserStatusOffline):
|
||||
is_active = user.status.was_online + datetime.timedelta(day=5) >= datetime.now()
|
||||
|
||||
if isinstance(user.status, UserStatusOnline):
|
||||
is_active = True
|
||||
|
||||
if not is_active:
|
||||
continue
|
||||
|
||||
if not User.exist(user.username, collection):
|
||||
|
|
Loading…
Reference in New Issue