Logging for mentions; fix format date accept movies time

This commit is contained in:
localhost_frssoft 2022-09-11 00:15:14 +03:00
parent 02ffb30fcb
commit 6ba859a308

View file

@ -6,6 +6,7 @@ import threading, time
from datetime import datetime from datetime import datetime
from dateutil.parser import parse as dateutilparse from dateutil.parser import parse as dateutilparse
from dateutil.relativedelta import relativedelta, TU, SU from dateutil.relativedelta import relativedelta, TU, SU
from loguru import logger
def get_control_mention(): def get_control_mention():
@ -18,7 +19,7 @@ def get_control_mention():
if get_state('last_thread_id'): if get_state('last_thread_id'):
time.sleep(30) time.sleep(30)
continue continue
logger.debug('Wait for from admin mention...')
notif = get_notifications() notif = get_notifications()
for i in notif: for i in notif:
if i['type'] != "mention": if i['type'] != "mention":
@ -27,13 +28,14 @@ def get_control_mention():
acct_mention = i['account']['acct'] acct_mention = i['account']['acct']
reply_to_id = i['status']['in_reply_to_id'] reply_to_id = i['status']['in_reply_to_id']
if acct_mention in admins_bot and seen == False and reply_to_id == None and now_week in (0, 6): if acct_mention in admins_bot and seen == False and reply_to_id == None and now_week in (0, 6):
logger.success(f'Найдено упоминание от {acct_mention}')
st_id = i['status']['id'] st_id = i['status']['id']
st_date = i['status']['created_at'] st_date = i['status']['created_at']
thread_created_at = dateutilparse(st_date) thread_created_at = dateutilparse(st_date)
delta = relativedelta(hour=hour_poll_posting, minute=0, second=0, weekday=TU(1)) delta = relativedelta(hour=hour_poll_posting, minute=0, second=0, weekday=TU(1))
stop_thread_scan = thread_created_at + delta stop_thread_scan = thread_created_at + delta
movies_accept_time = stop_thread_scan.strftime('%H:%M %d.%m.%Y MSK') movies_accept_time = stop_thread_scan.strftime('%H:%M %d.%m.%Y по Москве')
stop_thread_scan = time.mktime(time.struct_time(stop_thread_scan.timetuple())) stop_thread_scan = time.mktime(time.struct_time(stop_thread_scan.timetuple()))
if now_week == 6: # Фикс стыков двух недель. Если вс, то расчитываем на следующую неделю if now_week == 6: # Фикс стыков двух недель. Если вс, то расчитываем на следующую неделю