From d51107aa11f427091c0e9a812d21552c49952f49 Mon Sep 17 00:00:00 2001 From: Trevor Fitzgerald Date: Sat, 9 Nov 2024 08:54:37 -0500 Subject: [PATCH] write stream event output for debugging in sample script --- README.md | 4 ++-- scripts/berserk-connect-bots.py | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4cf91d4c..f52dac93 100644 --- a/README.md +++ b/README.md @@ -146,8 +146,8 @@ Then in `docker-compose.yml`add `- ./database:/data/db` to mongodb volumes To install the development version of [Berserk](https://github.com/lichess-org/berserk) and run a sample script against your local development site: ```bash -docker compose run --rm -w /berserk python \ - bash -c "pip install -e . && python /scripts/berserk-example.py" +docker compose run --rm -w /berserk python sh -c "pip install -e . && python /scripts/berserk-example.py" +docker compose run --rm -w /berserk python sh -c "pip install -e . && python /scripts/berserk-connect-bots.py" ``` ### Scala Metals (IDE helper): diff --git a/scripts/berserk-connect-bots.py b/scripts/berserk-connect-bots.py index 92f03a24..3e2d60d2 100644 --- a/scripts/berserk-connect-bots.py +++ b/scripts/berserk-connect-bots.py @@ -1,3 +1,4 @@ +import json import berserk import concurrent.futures @@ -5,6 +6,10 @@ def connect_bot(token): session = berserk.TokenSession(token) client = berserk.Client(session, base_url="http://nginx") generator = client.bots.stream_incoming_events() + + for event in generator: + print(token, json.dumps(event)) + return next(generator) with concurrent.futures.ThreadPoolExecutor(max_workers=9) as executor: