File size: 786 Bytes
3c948b5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# shared.py
import aiohttp

user_cash = {}
user_bets = {}

async def fetch_nhl_scores():
    async with aiohttp.ClientSession() as session:
        async with session.get("https://nhl-score-api.herokuapp.com/api/scores/latest") as response:
            return await response.json()

def load_database():
    global user_cash
    try:
        with open("database.txt", "r") as f:
            for line in f:
                parts = line.strip().split()
                if len(parts) == 2 and parts[1].startswith("cash(") and parts[1].endswith(")"):
                    user_id = int(parts[0])
                    cash = int(parts[1][5:-1])
                    user_cash[user_id] = cash
    except FileNotFoundError:
        print("No database found. Creating a new one.")

load_database()