Lilac subathon customisations

This commit is contained in:
2026-07-22 17:28:10 +03:00
parent 11c77bcc89
commit 297eb434d4
2 changed files with 52 additions and 29 deletions
+17 -3
View File
@@ -106,8 +106,8 @@ async def prepare_subathon(
if contrib.profileid:
profile = await profiler.get_profile(contrib.profileid)
assert profile is not None
name = profile.nickname or "Unknown"
user_id = str(profile.profileid)
name = profile.nickname
user_id = None
else:
name = "Anonymous"
user_id = None
@@ -196,7 +196,10 @@ class TimerChannel(Channel):
async def on_connection(self, websocket, event):
if not (cidstr := event.get("community")):
raise ValueError("Subathon timer connection missing communityid")
logger.warning("Subathon timer connection missing communityid")
await super().on_connection(websocket, event)
await self.send_sample(websocket=websocket)
return
elif not cidstr.isdigit():
raise ValueError("Community id provided is not an integer")
cid = int(cidstr)
@@ -214,6 +217,17 @@ class TimerChannel(Channel):
else:
await self.send_no_subathon(cid, websocket)
async def send_sample(self, websocket):
import json
import random
with open("sample-payload.json") as f:
payload = json.load(f)
ending = utc_now() + timedelta(seconds=10)
payload['args']['end_at'] = ending.isoformat()
payload['args']['total_contribution'] = random.choice(range(1, 150))
await self.send_event(payload, websocket=websocket)
async def del_connection(self, websocket):
for wss in self.communities.values():
wss.discard(websocket)