|
@@ -19,8 +19,9 @@ listen_to = ["st_request_wontfix@ej.sharix-app.org"]
|
|
|
proceed_to = ["numbers"]
|
|
|
|
|
|
# Новые параметры
|
|
|
+IS_INFINITE_REMINDER = False
|
|
|
DEFAULT_REMINDER_INTERVAL = 30 * 60 # 30 минут в секундах
|
|
|
-MAX_REMINDERS = 3 # Максимальное количество напоминаний (-1 для бесконечных уведомлений)
|
|
|
+MAX_REMINDERS = 3 # Максимальное количество напоминаний
|
|
|
DEFAULT_CHECK_INTERVAL = 5 * 60 # Проверка тикетов каждые 5 минут
|
|
|
|
|
|
tickets = {}
|
|
@@ -38,7 +39,7 @@ def send_reminder(user, ticket):
|
|
|
# # Здесь должен быть код для отправки сообщения пользователю
|
|
|
# print(f"Отправлено уведомление пользователю {user} о WONTFIX для тикета {ticket.id}")
|
|
|
|
|
|
-def process_in_progress_ticket(ticket, max_reminders, default_reminder_interval, start_time):
|
|
|
+def process_in_progress_ticket(ticket, max_reminders, default_reminder_interval, is_infinite_reminder, start_time):
|
|
|
bot.bot_log(botname+" "+str(datetime.now())+" "+"Тикет в обработчике\n")
|
|
|
tickets_new=jsreq.requestGetTicket_user(token, config.API_URL+f"tickets/api/ticket_list/{ticket.id}")
|
|
|
if tickets_new:
|
|
@@ -51,40 +52,16 @@ def process_in_progress_ticket(ticket, max_reminders, default_reminder_interval,
|
|
|
"last_date_reminder": start_time
|
|
|
}
|
|
|
|
|
|
- if (MAX_REMINDERS == -1 or tickets[ticket.id][ticket_new.id]['reminders'] < max_reminders) and (start_time - tickets[ticket.id][ticket_new.id]["last_date_reminder"]) > default_reminder_interval:
|
|
|
- send_reminder("st_request_in_process@ej.sharix-app.org", ticket_new)
|
|
|
+ if is_infinite_reminder or tickets[ticket.id][ticket_new.id]['reminders'] < max_reminders:
|
|
|
+ if (start_time - tickets[ticket.id][ticket_new.id]["last_date_reminder"]) > default_reminder_interval:
|
|
|
+ send_reminder("st_request_in_process@ej.sharix-app.org", ticket_new)
|
|
|
|
|
|
- tickets[ticket.id][ticket_new.id]["reminders"] += 1
|
|
|
- tickets[ticket.id][ticket_new.id]["last_date_reminder"] += start_time
|
|
|
-
|
|
|
+ tickets[ticket.id][ticket_new.id]["reminders"] += 1
|
|
|
+ tickets[ticket.id][ticket_new.id]["last_date_reminder"] += start_time
|
|
|
+ elif not is_infinite_reminder and tickets[ticket.id][ticket_new.id]['reminders'] >= max_reminders:
|
|
|
+ del tickets[ticket.id][ticket_new.id]
|
|
|
+ # Функция смены статуса на WONTFIX
|
|
|
|
|
|
- # start_time = datetime.now()
|
|
|
- # reminders_sent = 0
|
|
|
-
|
|
|
- # current_time = datetime.now()
|
|
|
- # time_in_progress = (current_time - start_time).total_seconds()
|
|
|
-
|
|
|
- # if timeout != INFINITE_TIMEOUT and time_in_progress > timeout:
|
|
|
- # # Превышен таймаут, меняем статус на WONTFIX
|
|
|
- # jsreq.requestPatchTicketUser(token, config.API_URL + f"tickets/api/ticket/{ticket.id}/", {"status": "WONTFIX"})
|
|
|
- # send_wontfix_notification(ticket.assigned_to, ticket)
|
|
|
- # break
|
|
|
-
|
|
|
- # if time_in_progress >= (reminders_sent + 1) * reminder_interval:
|
|
|
- # send_reminder(ticket.assigned_to, ticket)
|
|
|
- # reminders_sent += 1
|
|
|
-
|
|
|
- # if reminders_sent >= MAX_REMINDERS:
|
|
|
- # # Превышено максимальное количество напоминаний
|
|
|
- # jsreq.requestPatchTicketUser(token, config.API_URL + f"tickets/api/ticket/{ticket.id}/", {"status": "WONTFIX"})
|
|
|
- # send_wontfix_notification(ticket.assigned_to, ticket)
|
|
|
- # break
|
|
|
-
|
|
|
- # # Проверяем, не изменился ли статус тикета
|
|
|
- # updated_ticket_list = jsreq.requestGetTicket_user(token, config.API_URL + f"tickets/api/ticket/{ticket.id}/")
|
|
|
- # if updated_ticket_list and updated_ticket_list[0].status != "IN PROCESS":
|
|
|
- # break
|
|
|
-
|
|
|
|
|
|
def status_changer():
|
|
|
while True:
|
|
@@ -92,7 +69,7 @@ def status_changer():
|
|
|
for ticket in ticketlist:
|
|
|
bot.bot_log(f"{botname} {datetime.now().strftime('%Y-%m-%d')} Тикет {ticket.id} в обработке\n")
|
|
|
start_time = datetime.now()
|
|
|
- t1 = threading.Thread(target=process_in_progress_ticket, args=(ticket, MAX_REMINDERS, DEFAULT_REMINDER_INTERVAL, start_time))
|
|
|
+ t1 = threading.Thread(target=process_in_progress_ticket, args=(ticket, MAX_REMINDERS, DEFAULT_REMINDER_INTERVAL, IS_INFINITE_REMINDER, start_time))
|
|
|
t1.start()
|
|
|
t1.join() # Ожидаем завершения обработки тикета
|
|
|
time.sleep(DEFAULT_CHECK_INTERVAL)
|