-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTBA.py
More file actions
28 lines (21 loc) · 914 Bytes
/
TBA.py
File metadata and controls
28 lines (21 loc) · 914 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import tbapy
import os
class TBA:
def __init__(self, event):
self.API_KEY = os.getenv('TBA_API_KEY')
self.tba = tbapy.TBA(self.API_KEY)
self.event = event
def getstatus(self):
# Using this to test if I set it up correctly
print(self.API_KEY)
print(self.tba.status())
def verify_team(self, match_number, match_type, alliance, team):
# Checks if a team is on the specified alliance in a given match
match_data = self.tba.match(key=f"{self.event}_{match_type}m{match_number}")
for t in match_data.alliances[alliance]['team_keys']:
if f"frc{str(team)}" == t:
return True
return False
def get_match_score(self, match_number, match_type, alliance):
match_data = self.tba.match(key=f"{self.event}_{match_type}m{match_number}")
return match_data.alliances[alliance]['score']