mirror of
https://gitea.phreedom.club/localhost_frssoft/FMN_bot
synced 2024-11-22 10:39:18 +02:00
try automatically run thread if hour is 0
This commit is contained in:
parent
1558ab6a2d
commit
7930d5d996
|
@ -80,7 +80,7 @@ def get_status(status_id):
|
|||
logger.info(f'Retrying get status {status_id}')
|
||||
|
||||
|
||||
def post_status(text, reply_to_status_id=None, poll_options=None, poll_expires=345600, attachments=None):
|
||||
def post_status(text, reply_to_status_id=None, poll_options=None, poll_expires=345600, attachments=None, visibility='unlisted'):
|
||||
poll = None
|
||||
if poll_options is not None:
|
||||
poll = {
|
||||
|
@ -91,7 +91,7 @@ def post_status(text, reply_to_status_id=None, poll_options=None, poll_expires=3
|
|||
params = {
|
||||
"status": text,
|
||||
"in_reply_to_id": reply_to_status_id,
|
||||
"visibility": "unlisted",
|
||||
"visibility": visibility,
|
||||
"content_type": "text/plain",
|
||||
"language": "ru",
|
||||
"poll": poll
|
||||
|
|
|
@ -58,6 +58,33 @@ def get_control_mention():
|
|||
time.sleep(0.2)
|
||||
mark_as_read_notification(i['id'])
|
||||
|
||||
states_stor.states['max_mute_time'] = int(max_mute_time)
|
||||
states_stor.states['stop_thread_scan'] = int(stop_thread_scan)
|
||||
states_stor.states['last_thread_id'] = st_id
|
||||
write_states(states_stor.states)
|
||||
break
|
||||
if now_hour == 0:
|
||||
logger.warning(f'Автоматический триггер в полночи сработал')
|
||||
st_date = time_now
|
||||
thread_created_at = dateutilparse(st_date)
|
||||
|
||||
delta = relativedelta(hour=hour_poll_posting, minute=0, second=0, weekday=TU(1))
|
||||
stop_thread_scan = thread_created_at + delta
|
||||
movies_accept_time = stop_thread_scan.strftime('%H:%M %d.%m.%Y по Москве')
|
||||
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')
|
||||
st_id = post_status(start_collect_movies_text(movies_accept_time, next_movie_watching) + '\n\n@rf@mastodon.ml', None, attachments=[upload_attachment('src/FMN.webp')], "public")['id']
|
||||
|
||||
time.sleep(0.2)
|
||||
|
||||
states_stor.states['max_mute_time'] = int(max_mute_time)
|
||||
states_stor.states['stop_thread_scan'] = int(stop_thread_scan)
|
||||
states_stor.states['last_thread_id'] = st_id
|
||||
|
|
Loading…
Reference in New Issue