فهرست منبع

move get_init_data to extra module

blezz-tech 3 هفته پیش
والد
کامیت
e674bcb653
2فایلهای تغییر یافته به همراه14 افزوده شده و 11 حذف شده
  1. 12 0
      handlers/core/utils.py
  2. 2 11
      handlers/handlers/open_access_request_pending.py

+ 12 - 0
handlers/core/utils.py

@@ -0,0 +1,12 @@
+from classes.Ticket import Ticket
+from typing import List
+
+def get_init_data(status: int) -> List[Ticket]:
+    return [
+        Ticket(0, "t", 0,0,0,0,0,0,0,0,0,"note", 1),
+        Ticket(1, "t", 0,1,0,0,0,0,0,0,0,"note", 2),
+        Ticket(2, "t", 0,2,0,0,0,0,0,0,0,"note", 1),
+        Ticket(3, "t", 0,3,0,0,0,0,0,0,0,"note", 2),
+        Ticket(4, "t", 0,4,0,0,0,0,0,0,0,"note", 1),
+        Ticket(5, "t", 0,5,0,0,0,0,0,0,0,"note", 1),
+    ]

+ 2 - 11
handlers/handlers/open_access_request_pending.py

@@ -11,6 +11,7 @@ from classes.Ticket import Ticket
 from typing import List
 from concurrent.futures import ThreadPoolExecutor
 from utils.SystemdKiller import SystemdKiller
+from core.utils import get_init_data
 
 botname = "open_access_request_pending"
 operating_status = 320
@@ -67,7 +68,7 @@ def start_handler():
 
     logging.info(">>>>>  %s  |---| %s  <<<<<", JID, PASSWORD)
 
-    tickets: List[Ticket] = get_init_data()
+    tickets: List[Ticket] = get_init_data(operating_status)
 
     with ThreadPoolExecutor() as executor:
         killer = SystemdKiller()
@@ -118,16 +119,6 @@ def processing(ticket: Ticket) -> None:
     logging.debug(f"Конец обработки тикета {ticket.id}")
 
 
-def get_init_data() -> List[Ticket]:
-    return [
-        Ticket(0, "t", 0,0,0,0,0,0,0,0,0,"note",INTERVAL_ATTEMPTS - 2),
-        Ticket(1, "t", 0,1,0,0,0,0,0,0,0,"note",INTERVAL_ATTEMPTS + 1),
-        Ticket(2, "t", 0,2,0,0,0,0,0,0,0,"note",INTERVAL_ATTEMPTS - 1),
-        Ticket(3, "t", 0,3,0,0,0,0,0,0,0,"note",INTERVAL_ATTEMPTS + 2),
-        Ticket(4, "t", 0,4,0,0,0,0,0,0,0,"note",INTERVAL_ATTEMPTS + 1),
-        Ticket(5, "t", 0,5,0,0,0,0,0,0,0,"note",INTERVAL_ATTEMPTS - 1),
-    ]
-
 def send_notification_to_admins(ticket: Ticket, admins: List[str], message: str) -> None:
     """Отправка уведомления администратору о новом тикете."""
     for admin in admins: