Boilerplate Python server for Maverick.
Demonstrates two simple ways of sending instructions:
- Manually, using the stdin to send commands to Maverick.
- Fetching messages from a Telegram entity (e.g. a group), parsing them into
BetRequests, and forwarding them to Maverick.
- Clone the repo
git clone https://github.com/t00ts/maverick-servercd maverick-server
- Optional: Set up a Python virtual environment
python -m venv venvsource venv/bin/activate
- Install dependencies
pip install -r requirements.txt
- Fill in your Telegram API ID and Hash in
config.toml. You can get these from https://my.telegram.org. - Run
python telegram_setup.pyto set up your Telegram session and take note of the entity ID for the group you're interested in subscribing to. - Add that entity ID to your
config.toml, in thegroup_entitiesarray. - Adjust the
stakefor your betting strategy in that same file. - Save and close the file.
All incoming messages will be sent to the parse_telegram_msg function in the custom_telegram.py file. This is where you filter and parse messages, and construct the BetRequest object that will be sent to Maverick. You'll find an example implementation of this function in the file, which you naturally will need to tailor to your needs, dictated by the format of the messages you receive.
💡 Pro tip: To understand how to construct a valid
BetRequestJSON object, run thebetreqbinary that is included in your Maverick bundle. You will be able to createBetRequestobjects interactively and gain detailed insights into how to build your own.
All Maverick incoming responses will be sent to the process_maverick_msg function in the custom_maverick.py file. Here's where you can implement your logic for bet tracking, logging, retry attempts, cashflow management, etc. For more information about Maverick responses, see the Maverick docs.
Launch two side-by-side terminal sessions:
| Terminal 1 | Terminal 2 |
|---|---|
./run_server.sh |
./server_output.sh |
You can send commands manually by copying and pasting the BetRequest JSON objects you want to send into the console where you're running the server, and pressing enter. This very handy when combined with the betreq utility and will prove useful for testing your betting strategy, or for sending commands to Maverick without having to wait for a Telegram message to come through.
In Maverick's config.toml, set the addr of your [server] block to point to your running websocket server:
[server]
addr = "ws://localhost:5999"
max_retries = 10Run Maverick, and you should see the connection has been established successfully:
INFO maverick::server: Connecting to server (ws://localhost:5999/)
INFO maverick::server: Connection established successfully.