Skip to content

Commit

Permalink
write stream event output for debugging in sample script
Browse files Browse the repository at this point in the history
  • Loading branch information
fitztrev committed Nov 9, 2024
1 parent 150956e commit d51107a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
5 changes: 5 additions & 0 deletions scripts/berserk-connect-bots.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import json
import berserk
import concurrent.futures

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:
Expand Down

0 comments on commit d51107a

Please sign in to comment.