Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
BoQsc committed Aug 18, 2024
1 parent d36d559 commit 9e90528
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
10 changes: 10 additions & 0 deletions webserver/Webserver-testing/Webserver/chat-message-processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ def get_player_name(pltfm_id, player_status):
return player_name
return pltfm_id # Return pltfm_id if no matching player name is found

def get_machine_timezone_offset():
from datetime import datetime
import time

offset_seconds = time.timezone if time.localtime().tm_isdst == 0 else time.altzone
offset_hours = offset_seconds / 3600
current_time_zone_offset = f'{offset_hours:+.0f}:00'
return current_time_zone_offset

def process_log_file(file_path, data, player_status):
chat_messages = data.get('chat_messages', [])
last_processed_position = data.get('last_processed_position', 0)
Expand All @@ -43,6 +52,7 @@ def process_log_file(file_path, data, player_status):
timestamp, pltfm_id, entity_id, chat_type, message = match.groups()
player_name = get_player_name(pltfm_id, player_status)
chat_messages.append({
'machine_timezone_offset': get_machine_timezone_offset(),
'timestamp': datetime.strptime(timestamp, '%Y-%m-%dT%H:%M:%S'),
'pltfm_id': pltfm_id,
'player_name': player_name,
Expand Down
5 changes: 5 additions & 0 deletions webserver/Webserver-testing/Webserver/chat_analysis.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"chat_messages": [
{
"machine_timezone_offset": "-3:00",
"timestamp": "2024-08-17T15:04:26",
"pltfm_id": "Steam_76561198072601792",
"player_name": "boqsc",
Expand All @@ -9,6 +10,7 @@
"message": "gewwta"
},
{
"machine_timezone_offset": "-3:00",
"timestamp": "2024-08-17T15:10:01",
"pltfm_id": "Steam_76561198072601792",
"player_name": "boqsc",
Expand All @@ -17,6 +19,7 @@
"message": "aa"
},
{
"machine_timezone_offset": "-3:00",
"timestamp": "2024-08-17T15:10:26",
"pltfm_id": "Steam_76561198072601792",
"player_name": "boqsc",
Expand All @@ -25,6 +28,7 @@
"message": "dsf"
},
{
"machine_timezone_offset": "-3:00",
"timestamp": "2024-08-17T15:11:26",
"pltfm_id": "Steam_76561198072601792",
"player_name": "boqsc",
Expand All @@ -33,6 +37,7 @@
"message": "test"
},
{
"machine_timezone_offset": "-3:00",
"timestamp": "2024-08-17T15:14:26",
"pltfm_id": "Steam_76561198072601792",
"player_name": "boqsc",
Expand Down

0 comments on commit 9e90528

Please sign in to comment.