coollsd commited on
Commit
3c948b5
1 Parent(s): cf00815

Create shared.py

Browse files
Files changed (1) hide show
  1. shared.py +25 -0
shared.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # shared.py
2
+ import aiohttp
3
+
4
+ user_cash = {}
5
+ user_bets = {}
6
+
7
+ async def fetch_nhl_scores():
8
+ async with aiohttp.ClientSession() as session:
9
+ async with session.get("https://nhl-score-api.herokuapp.com/api/scores/latest") as response:
10
+ return await response.json()
11
+
12
+ def load_database():
13
+ global user_cash
14
+ try:
15
+ with open("database.txt", "r") as f:
16
+ for line in f:
17
+ parts = line.strip().split()
18
+ if len(parts) == 2 and parts[1].startswith("cash(") and parts[1].endswith(")"):
19
+ user_id = int(parts[0])
20
+ cash = int(parts[1][5:-1])
21
+ user_cash[user_id] = cash
22
+ except FileNotFoundError:
23
+ print("No database found. Creating a new one.")
24
+
25
+ load_database()