mirror of
https://gitea.phreedom.club/localhost_frssoft/FMN_bot.git
synced 2024-11-23 13:43:01 +00:00
Some fixes
Теперь здесь же будет вызываться проверка победившего фильма когда опрос будет окончен
This commit is contained in:
parent
25bf04fe5a
commit
a26bd29e58
@ -11,7 +11,7 @@ from src.kinopoisk_api import get_kinopoisk_movie
|
||||
from src.imdb_datasets_worker import get_title_by_id
|
||||
from src.fmn_database import add_movie_to_poll, get_already_watched
|
||||
from src.fmn_states_db import get_state, add_state
|
||||
from src.fmn_poll import create_poll_movies
|
||||
from src.fmn_poll import create_poll_movies, get_winner_movie
|
||||
|
||||
logger = logging.getLogger('thread_listener')
|
||||
|
||||
@ -37,27 +37,24 @@ def scan_context_thread():
|
||||
while True:
|
||||
status_id = get_state('last_thread_id')
|
||||
poll_created = get_state('poll_status_id')
|
||||
stop_thread_scan = get_state('stop_thread_scan')
|
||||
flag_scan = 0
|
||||
time_now = time.time()
|
||||
while status_id is None:
|
||||
time_now = int(time.time())
|
||||
while status_id is None or stop_thread_scan is None:
|
||||
status_id = get_state('last_thread_id')
|
||||
if status_id and flag_scan == 0:
|
||||
thread_created_at = get_status(status_id)['created_at']
|
||||
thread_created_at = dateutilparse(thread_created_at)
|
||||
delta = relativedelta(hour=hour_poll_posting, minute=0, second=0, weekday=TU(1))
|
||||
stop_thread_scan = thread_created_at + delta
|
||||
logger.info('Сбор будет завершен в ' + stop_thread_scan.strftime('%c'))
|
||||
stop_thread_scan = time.mktime(time.struct_time(stop_thread_scan.timetuple()))
|
||||
flag_scan = 1
|
||||
stop_thread_scan = get_state('stop_thread_scan')
|
||||
time.sleep(1)
|
||||
|
||||
if int(time_now) >= int(stop_thread_scan):
|
||||
if time_now >= int(stop_thread_scan):
|
||||
logger.debug('Сбор завершён, сканирование треда на опоздавших')
|
||||
if poll_created is None:
|
||||
create_poll_movies()
|
||||
poll_created = get_state('poll_status_id')
|
||||
else:
|
||||
if time_now >= int(get_state('poll_expires_at')):
|
||||
get_winner_movie(poll_created)
|
||||
else:
|
||||
endings = stop_thread_scan - time_now
|
||||
endings = int(stop_thread_scan) - time_now
|
||||
logger.debug(f'Осталось до закрытия сбора: {endings}')
|
||||
descendants = get_status_context(status_id)['descendants']
|
||||
replyed = []
|
||||
|
Loading…
Reference in New Issue
Block a user