MCPcopy Index your code
hub / github.com/HiddenCodeDevs/BlumTelegramBot / check_payload_server

Function check_payload_server

bot/utils/payload.py:5–39  ·  view source on GitHub ↗
(payload_server_url: str, full_test: bool = False)

Source from the content-addressed store, hash-verified

3from bot.utils.logger import logger
4
5async def check_payload_server(payload_server_url: str, full_test: bool = False) -> bool:
6 url = f"{payload_server_url}/status"
7
8 if full_test and "https://" in payload_server_url and ("localhost:" in payload_server_url or "127.0.0.1:" in payload_server_url) :
9 logger.warning("Are you sure you specified the correct protocol? "
10 "On local machines, <r>https</r> is usually not used!")
11
12 async with ClientSession() as session:
13 try:
14 async with session.get(url, timeout=3) as response:
15 result = await response.json()
16 if response.status != 200 or result.get("status") != "ok":
17 return False
18 if result.get("version", 0) < 2:
19 logger.warning("<y>You need to update BlumPayloadGenerator, used old version</y>")
20 return False
21 if result.get("version") > 2:
22 logger.warning("<y>Your BlumTelegramBot script is out of date and needs to be updated.</y>")
23 return False
24 if full_test:
25 test_game_id = "0000test-game-iden-tifi-cation123456"
26 asset_clicks = {
27 "BOMB": {"clicks": 0},
28 "CLOVER": {"clicks": 150},
29 "FREEZE": {"clicks": 0},
30 "HARRIS": {"clicks": 0},
31 "TRUMP": {"clicks": 300}
32 }
33 earned_points = {"BP": {"amount": 150 + 300 * 5}}
34 payload = await get_payload(payload_server_url, test_game_id, earned_points, asset_clicks)
35 return len(payload) == 684
36 return True
37 except (TimeoutError, ClientConnectorError):
38 logger.debug(f"Try connect to payload server ({url}) failed...")
39 return False
40
41async def get_payload(payload_server_url: str, game_id: str, earned_points: dict, asset_clicks: dict) -> str | None:
42 async with ClientSession() as session:

Callers 2

run_tasksFunction · 0.90
play_drop_gameMethod · 0.90

Calls 2

get_payloadFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected