mirror of
https://git.phreedom.club/localhost_frssoft/FMN_bot.git
synced 2024-11-24 22:40:57 +01:00
Fix next FMN watching week
This commit is contained in:
parent
844480b02a
commit
f3ef0e4531
|
@ -10,7 +10,8 @@ from dateutil.relativedelta import relativedelta, TU, SU
|
||||||
|
|
||||||
def get_control_mention():
|
def get_control_mention():
|
||||||
while True:
|
while True:
|
||||||
now_week = datetime.now().weekday()
|
time_now = datetime.now()
|
||||||
|
now_week = time_now.weekday()
|
||||||
if now_week not in (0, 6):
|
if now_week not in (0, 6):
|
||||||
time.sleep(30)
|
time.sleep(30)
|
||||||
continue
|
continue
|
||||||
|
@ -26,20 +27,25 @@ 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):
|
||||||
time_now = datetime.now()
|
|
||||||
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))
|
||||||
next_movie_watching_delta = relativedelta(hour=fmn_next_watching_hour, minute=0, second=0, weekday=SU(1))
|
|
||||||
stop_thread_scan = thread_created_at + delta
|
stop_thread_scan = thread_created_at + delta
|
||||||
next_movie_watching = time_now + next_movie_watching_delta
|
|
||||||
max_mute_time = time.mktime(time.struct_time(next_movie_watching.timetuple()))
|
|
||||||
next_movie_watching = next_movie_watching.strftime('%d.%m.%Y')
|
|
||||||
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 MSK')
|
||||||
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: # Фикс стыков двух недель. Если вс, то расчитываем на следующую неделю
|
||||||
|
next_week = 2
|
||||||
|
else:
|
||||||
|
next_week = 1
|
||||||
|
next_movie_watching_delta = relativedelta(hour=fmn_next_watching_hour, minute=0, second=0, weekday=SU(next_week))
|
||||||
|
next_movie_watching = time_now + next_movie_watching_delta
|
||||||
|
max_mute_time = time.mktime(time.struct_time(next_movie_watching.timetuple())) # Глушение до следующего сеанса FMN.
|
||||||
|
next_movie_watching = next_movie_watching.strftime('%d.%m.%Y')
|
||||||
post_status(start_collect_movies_text(movies_accept_time, next_movie_watching), st_id, attachments=[upload_attachment('src/FMN.png')])
|
post_status(start_collect_movies_text(movies_accept_time, next_movie_watching), st_id, attachments=[upload_attachment('src/FMN.png')])
|
||||||
|
|
||||||
time.sleep(0.2)
|
time.sleep(0.2)
|
||||||
mark_as_read_notification(i['id'])
|
mark_as_read_notification(i['id'])
|
||||||
add_state('max_mute_time', int(max_mute_time))
|
add_state('max_mute_time', int(max_mute_time))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user