Update tracker.py
Browse files- tracker.py +7 -5
tracker.py
CHANGED
@@ -43,15 +43,15 @@ def fetch_match_data():
|
|
43 |
response.raise_for_status()
|
44 |
return response.json()[0]
|
45 |
|
46 |
-
def increment_score(player_id):
|
47 |
data = {
|
48 |
"player_id": player_id,
|
49 |
-
"score":
|
50 |
"operation": "increment"
|
51 |
}
|
52 |
response = requests.post(keepthescore_api, json=data)
|
53 |
response.raise_for_status()
|
54 |
-
print(f"Incremented score for player ID {player_id}")
|
55 |
|
56 |
def send_discord_message(match_data):
|
57 |
clubs = match_data["clubs"]
|
@@ -93,10 +93,11 @@ def send_discord_message(match_data):
|
|
93 |
goals = int(player["goals"])
|
94 |
assists = player["assists"]
|
95 |
|
96 |
-
|
|
|
97 |
player_id = player_ids.get(player_name)
|
98 |
if player_id:
|
99 |
-
increment_score(player_id)
|
100 |
|
101 |
red_card_icon = "π₯ " if player["redcards"] == "1" else ""
|
102 |
player_display_name = f"{red_card_icon}{custom_name} ({position})"
|
@@ -118,6 +119,7 @@ def send_discord_message(match_data):
|
|
118 |
if rejection_fc["losses"] == "1":
|
119 |
send_motivational_message()
|
120 |
|
|
|
121 |
def send_motivational_message():
|
122 |
message = random.choice(motivational_quotes)
|
123 |
|
|
|
43 |
response.raise_for_status()
|
44 |
return response.json()[0]
|
45 |
|
46 |
+
def increment_score(player_id, increment=1):
|
47 |
data = {
|
48 |
"player_id": player_id,
|
49 |
+
"score": increment,
|
50 |
"operation": "increment"
|
51 |
}
|
52 |
response = requests.post(keepthescore_api, json=data)
|
53 |
response.raise_for_status()
|
54 |
+
print(f"Incremented score by {increment} for player ID {player_id}")
|
55 |
|
56 |
def send_discord_message(match_data):
|
57 |
clubs = match_data["clubs"]
|
|
|
93 |
goals = int(player["goals"])
|
94 |
assists = player["assists"]
|
95 |
|
96 |
+
increment = goals // 3
|
97 |
+
if increment > 0:
|
98 |
player_id = player_ids.get(player_name)
|
99 |
if player_id:
|
100 |
+
increment_score(player_id, increment)
|
101 |
|
102 |
red_card_icon = "π₯ " if player["redcards"] == "1" else ""
|
103 |
player_display_name = f"{red_card_icon}{custom_name} ({position})"
|
|
|
119 |
if rejection_fc["losses"] == "1":
|
120 |
send_motivational_message()
|
121 |
|
122 |
+
|
123 |
def send_motivational_message():
|
124 |
message = random.choice(motivational_quotes)
|
125 |
|