Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
MBetterc
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Mbetter
MBetterc
Commits
4ae8c528
Commit
4ae8c528
authored
Nov 17, 2025
by
Stefy Lanza (nextime / spora )
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update templates
parent
3930037f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
71 additions
and
18 deletions
+71
-18
client.py
mbetterclient/api_client/client.py
+39
-14
games_thread.py
mbetterclient/core/games_thread.py
+28
-0
default.html
mbetterclient/qt_player/templates/default.html
+4
-4
No files found.
mbetterclient/api_client/client.py
View file @
4ae8c528
...
...
@@ -873,6 +873,22 @@ class APIClient(ThreadedComponent):
)
self
.
message_bus
.
publish
(
response_message
)
# Check if this is a successful fixture update that might trigger game start
if
endpoint
.
name
==
'fastapi_main'
and
processed_data
.
get
(
'synchronized_matches'
,
0
)
>
0
:
logger
.
info
(
f
"Fixture update successful - {processed_data.get('synchronized_matches')} matches synchronized"
)
# Send a message to trigger game start check
game_start_check_message
=
Message
(
type
=
MessageType
.
SYSTEM_STATUS
,
sender
=
self
.
name
,
data
=
{
'status'
:
'fixture_update_completed'
,
'synchronized_matches'
:
processed_data
.
get
(
'synchronized_matches'
,
0
),
'downloaded_zips'
:
processed_data
.
get
(
'downloaded_zips'
,
0
),
'timestamp'
:
datetime
.
utcnow
()
.
isoformat
()
}
)
self
.
message_bus
.
publish
(
game_start_check_message
)
logger
.
debug
(
f
"API request successful: {endpoint.name}"
)
except
Exception
as
e
:
...
...
@@ -1051,7 +1067,7 @@ class APIClient(ThreadedComponent):
current_interval
=
current_api_config
.
get
(
"api_interval"
,
1800
)
# 30 minutes default
if
not
old_has_token
and
new_has_token
:
# Token was added - start timer
# Token was added - start timer
and trigger immediate fixture update
fastapi_endpoint
.
enabled
=
True
fastapi_endpoint
.
interval
=
current_interval
fastapi_endpoint
.
retry_attempts
=
10
...
...
@@ -1061,6 +1077,10 @@ class APIClient(ThreadedComponent):
logger
.
info
(
f
"FastAPI timer started - token configured, {current_interval} second intervals enabled"
)
# Trigger immediate fixture update check
logger
.
info
(
"Token configured - triggering immediate fixture update check"
)
self
.
_execute_endpoint_request
(
fastapi_endpoint
)
# Send immediate status update
status_message
=
Message
(
type
=
MessageType
.
SYSTEM_STATUS
,
...
...
@@ -1069,7 +1089,8 @@ class APIClient(ThreadedComponent):
"status"
:
"timer_started"
,
"endpoint"
:
"fastapi_main"
,
"reason"
:
"token_configured"
,
"interval_seconds"
:
current_interval
"interval_seconds"
:
current_interval
,
"immediate_update_triggered"
:
True
}
)
self
.
message_bus
.
publish
(
status_message
)
...
...
@@ -1096,12 +1117,16 @@ class APIClient(ThreadedComponent):
self
.
message_bus
.
publish
(
status_message
)
elif
old_has_token
and
new_has_token
and
old_token
!=
new_token
:
# Token was changed - keep timer running but reset failure count
# Token was changed - keep timer running but reset failure count
and trigger immediate update
fastapi_endpoint
.
consecutive_failures
=
0
fastapi_endpoint
.
last_request
=
None
# Trigger immediate request with new token
logger
.
info
(
"FastAPI token updated - timer continues with new authentication"
)
# Trigger immediate fixture update check with new token
logger
.
info
(
"Token updated - triggering immediate fixture update check with new token"
)
self
.
_execute_endpoint_request
(
fastapi_endpoint
)
except
Exception
as
e
:
logger
.
error
(
f
"Failed to handle token change: {e}"
)
...
...
mbetterclient/core/games_thread.py
View file @
4ae8c528
...
...
@@ -42,6 +42,7 @@ class GamesThread(ThreadedComponent):
self
.
message_bus
.
subscribe
(
self
.
name
,
MessageType
.
MATCH_START
,
self
.
_handle_match_start
)
self
.
message_bus
.
subscribe
(
self
.
name
,
MessageType
.
PLAY_VIDEO_MATCH_DONE
,
self
.
_handle_play_video_match_done
)
self
.
message_bus
.
subscribe
(
self
.
name
,
MessageType
.
MATCH_DONE
,
self
.
_handle_match_done
)
self
.
message_bus
.
subscribe
(
self
.
name
,
MessageType
.
SYSTEM_STATUS
,
self
.
_handle_system_status
)
# Send ready status
ready_message
=
MessageBuilder
.
system_status
(
...
...
@@ -1313,6 +1314,33 @@ class GamesThread(ThreadedComponent):
except
Exception
as
e
:
logger
.
error
(
f
"Failed to handle MATCH_DONE message: {e}"
)
def
_handle_system_status
(
self
,
message
:
Message
):
"""Handle SYSTEM_STATUS messages, particularly fixture update completion"""
try
:
status
=
message
.
data
.
get
(
"status"
)
if
status
==
"fixture_update_completed"
:
synchronized_matches
=
message
.
data
.
get
(
"synchronized_matches"
,
0
)
downloaded_zips
=
message
.
data
.
get
(
"downloaded_zips"
,
0
)
logger
.
info
(
f
"Fixture update completed: {synchronized_matches} matches synchronized, {downloaded_zips} ZIPs downloaded"
)
# Check if we should start a game now that fixtures are available
if
synchronized_matches
>
0
and
not
self
.
game_active
:
logger
.
info
(
"New fixtures available and no game is active - attempting to start game"
)
# Send START_GAME message to ourselves to trigger game start
start_game_message
=
Message
(
type
=
MessageType
.
START_GAME
,
sender
=
self
.
name
,
recipient
=
self
.
name
,
data
=
{
"timestamp"
:
time
.
time
()
}
)
self
.
message_bus
.
publish
(
start_game_message
)
except
Exception
as
e
:
logger
.
error
(
f
"Failed to handle system status message: {e}"
)
def
_set_match_status
(
self
,
match_id
:
int
,
status
:
str
):
"""Set match status in database"""
try
:
...
...
mbetterclient/qt_player/templates/default.html
View file @
4ae8c528
...
...
@@ -2,7 +2,7 @@
<html>
<head>
<meta
charset=
"utf-8"
>
<title>
Text Message Overlay
</title>
<title>
MBetther system
</title>
<style>
*
{
margin
:
0
;
...
...
@@ -214,8 +214,8 @@
<div
class=
"overlay-container"
>
<div
class=
"message-panel"
id=
"messagePanel"
>
<div
class=
"message-icon"
id=
"messageIcon"
>
📢
</div>
<div
class=
"message-title"
id=
"messageTitle"
>
Announcement
</div>
<div
class=
"message-content"
id=
"messageContent"
>
This is a custom message from the system
.
</div>
<div
class=
"message-title"
id=
"messageTitle"
>
Mbetter Game
</div>
<div
class=
"message-content"
id=
"messageContent"
>
Waiting for game to start...
.
</div>
</div>
</div>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment