1. добавил scheduler для онлайн матчей и турнирки
2. добавил в расписание тура маски для счета и времени Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
70
agent.py
70
agent.py
@@ -5,6 +5,9 @@ import socket
|
||||
import uuid
|
||||
from urllib.parse import urlencode
|
||||
from xml.etree import ElementTree as ET
|
||||
import os
|
||||
import sys
|
||||
import ctypes
|
||||
|
||||
import requests
|
||||
import websockets
|
||||
@@ -18,6 +21,71 @@ POLL_INTERVAL = 3
|
||||
REQUEST_TIMEOUT = 3
|
||||
RECONNECT_DELAY = 5
|
||||
|
||||
def resource_path(relative_path: str) -> str:
|
||||
try:
|
||||
base_path = sys._MEIPASS
|
||||
except Exception:
|
||||
base_path = os.path.abspath(".")
|
||||
return os.path.join(base_path, relative_path)
|
||||
|
||||
|
||||
def setup_green_console():
|
||||
if os.name != "nt":
|
||||
return
|
||||
|
||||
kernel32 = ctypes.windll.kernel32
|
||||
h_out = kernel32.GetStdHandle(-11) # STD_OUTPUT_HANDLE
|
||||
|
||||
mode = ctypes.c_uint()
|
||||
if kernel32.GetConsoleMode(h_out, ctypes.byref(mode)):
|
||||
kernel32.SetConsoleMode(h_out, mode.value | 0x0004) # ENABLE_VIRTUAL_TERMINAL_PROCESSING
|
||||
|
||||
# зелёный текст по умолчанию
|
||||
print("\033[92m", end="")
|
||||
|
||||
|
||||
def set_console_icon():
|
||||
if os.name != "nt":
|
||||
return
|
||||
|
||||
ico_path = resource_path("app.ico")
|
||||
if not os.path.exists(ico_path):
|
||||
return
|
||||
|
||||
user32 = ctypes.windll.user32
|
||||
|
||||
# AppUserModelID помогает Windows корректнее показывать иконку приложения
|
||||
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID("my.agent.console")
|
||||
|
||||
hwnd = kernel32_get_console_window()
|
||||
if not hwnd:
|
||||
return
|
||||
|
||||
IMAGE_ICON = 1
|
||||
LR_LOADFROMFILE = 0x00000010
|
||||
WM_SETICON = 0x0080
|
||||
ICON_SMALL = 0
|
||||
ICON_BIG = 1
|
||||
|
||||
hicon = user32.LoadImageW(
|
||||
None,
|
||||
ico_path,
|
||||
IMAGE_ICON,
|
||||
0,
|
||||
0,
|
||||
LR_LOADFROMFILE
|
||||
)
|
||||
if hicon:
|
||||
user32.SendMessageW(hwnd, WM_SETICON, ICON_SMALL, hicon)
|
||||
user32.SendMessageW(hwnd, WM_SETICON, ICON_BIG, hicon)
|
||||
|
||||
|
||||
def kernel32_get_console_window():
|
||||
try:
|
||||
return ctypes.windll.kernel32.GetConsoleWindow()
|
||||
except Exception:
|
||||
return 0
|
||||
|
||||
|
||||
def read_vmix_dynamic_values():
|
||||
try:
|
||||
@@ -185,4 +253,6 @@ async def run_agent():
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
setup_green_console()
|
||||
set_console_icon()
|
||||
asyncio.run(run_agent())
|
||||
|
||||
Reference in New Issue
Block a user