SportyClaw Autoplacer is a Telegram-driven SportyBet automation suite that pulls booking codes from your chats, runs Selenium to place bets, and enforces a daily allocation cap based on a dynamic risk engine so only a limited portion of the balance is used each day.
- Telegram listener (
main.py,bot/listener.py): polls Telegram for text updates, ignores unauthorized senders, extracts SportyBet booking codes viabot/parser.py, and invokessportybet.client.place_bet_with_codewhile checking the daily allocation. The Selenium client logs into SportyBet, enables the SportyInsure “One Cut” option, and stakes the computed amount before confirming the ticket. Successful bets include a quick allocation countdown in the reply; if the day’s allocation is gone, it replies with an exhaustion warning. - Telethon listener (optional) (
bot/telethon_listener.py): uses your personal Telegram account to watch configured groups/chats and pushes incoming text through the same authorization/parsing/placement pipeline used by the bot listener. - Bankroll engine (
engine.py,bankroll.py): every morning the bot scrapes the current SportyBet balance, computes a daily allocation cap from dynamic tier anchors, and spreads stakes across up to 30 bets. Unused allocation remains in the account and is included the next day when the balance is refreshed. - Health + reporting (
health.py,bot/commands.py,reporter.py): a HTTP/healthendpoint plus a/healthTelegram command that both output the latest stats, including allocation status and profit/loss. Daily reports scrape SportyBet, marry the scraped ledger with the in-memory stats, and DM the owner chat as Markdown. - Mocking & pytest coverage (
bot/mock_handler.py,tests/*): the parser, listener, bankroll, and health handlers are all exercised via pytest, and the mock update/message helpers let you run listener tests without Telegram or Selenium.
- Populate
.envwith at leastBOT_TOKEN,OWNER_CHAT_ID,ALLOWED_USER_ID, and the SportyBet credentials (SPORTYBET_PHONE,SPORTYBET_PASSWORD). If you want to authorize additional Telegram users (e.g., people in other groups), setALLOWED_USER_IDSto a comma-separated list of their numeric IDs; the listener accepts messages from anyone named inALLOWED_USER_IDorALLOWED_USER_IDS. To change the daily cap on how many bets can be placed, setMAX_BETS_PER_DAY(defaults to 30). To force/healthto refresh the live SportyBet balance, setHEALTH_REFRESH_BALANCE=1(default). - (Optional) Enable Telethon user-account monitoring by setting
TELETHON_ENABLED=1plusTELETHON_API_ID,TELETHON_API_HASH, andTELETHON_CHATSin.env. You can also setTELETHON_PHONEfor first-time login andTELETHON_REPLY_IN_CHAT=1if you want placement replies inside the monitored group. - Install dependencies (ideally inside a virtualenv) with
python -m pip install -r requirements.txt. - Run
python main.py; the health server and Telegram polling start automatically. If Telethon is enabled, the Telethon listener also starts in the background. - Send booking codes through Telegram (or via the Telegram Bot API/ Postman) and keep an eye on
/healthto monitor the bankroll/quota breakdown.
- The bot initializes the daily allocation by scraping SportyBet, parsing the balance string into a float (
bankroll.parse_balance), and runningbankroll.initialize_from_amount, which applies the dynamic tier anchors inengine.py. - Before each bet,
listener.handle_messageverifiesbankroll.has_available_allocation()is true, reserves a stake (bankroll.reserve_stake()), and on success reports how much allocation and how many bet slots remain. Failed bets release the stake back into availability so it can be retried. - At midnight the scheduled job
run_daily_resetresets both the stats and the bankroll (bankroll.reset()), then refreshes the balance again for the new day. Unused allocation remains in the account and is re-evaluated during the next refresh.
- Run
python -m pytest testsfor parser, listener, health, and bankroll coverage. - The
/healthHTTP endpoint and Telegram command share the same payload, showing both the ongoing stats and the remaining allocation/bet slots.
- Selenium/Telegram packages may not be installed on every machine; use a virtualenv if the system rejects
pip installin this repo. - The parser ignores common words (
BOOKING,CODE, etc.) and runs case-insensitive matching to avoid false positives. Adjust the regexes inbot/parser.pyif your booking-code format differs.
Never Give Up,