RapidTipster (2023)
Side business with a partner - Python, Selenium, Telegram bots, Blazor, Docker
RapidTipster was my first attempt at a product, not a one-off script: a small sports-tips service I ran with a partner. A tipster Telegram channel posts when someone thinks odds have moved; we watch that feed, pull current bookmaker prices from OddsPortal, and post to our channel only when the drop still looks like value against the best price on the board.
It ran live with paying subscribers for a while, then we stopped. The story worth telling is everything around that loop: scraping, mappings, bots, a bare-metal subscription model, and deploying it where I could close the laptop.
(Year is approximate - pin file says Python 3.7 / .NET 6 / Selenium 4.9. Correct me if you remember differently.)
The pipeline
One message in, one tip out (or a log line explaining why not):
Tipster Telegram channel
|
v Telethon (user session), skip already-seen message ids
Fetcher + new_messages.json
|
v line parse: sport, league, teams, period, bet type, old/new odds
link_inputs.py
|
v fuzzy team match on OddsPortal league pages (SequenceMatcher)
match_finder.py
|
v Selenium + BeautifulSoup + lxml, all bookmakers on the coupon
collect_odds.py
|
v partner's value formula; if still cheap enough, format tip
recommender.py
|
+---> our Telegram channel (Bot API post)
+---> recommendations.csv
+---> logger (structured lines -> JSON for the site)
Blazor admin <--- same JSON/CSV on a Docker volume
core.py wakes every 3 minutes (schedule). Each pass:
- Read pending messages.
- Build an OddsPortal URL when the bet type is known.
- Skip known bad cases (unknown league, no match on the page, zero fuzzy score).
- Collect odds; do not recommend the same fixture twice (
collected_matches.json). - Fetch again so the next cycle is fresh.
- Turn the text log into
logger.jsonfor the website.
Failure modes are named tokens (no-league, no-match, zero-score, Too Late) so the loop logs and continues instead of dying mid-night.
The value rule
My partner’s rule lived in notebooks as a chart before it lived in code. In production:
ratio = (dropped_odd - 1) / (best_odd - 1)
dropped_odd= the new price from the source tip (home or away side that moved).best_odd= the highest price we just read from OddsPortal for that same selection.
If ratio < 0.85, we post. The channel message includes match context, bet side, best price and which bookmakers sit there, a 0-10 “tip value” scaled from how far under 0.85 the ratio is, and a floor: “do not bet below {X}” where X is the price that would push the ratio back to 0.85.
We use net odds (price - 1) because that is the profit part of a decimal quote, not the headline number.
Too Late: inside 5 minutes before kickoff we still append the row to CSV but do not send (Too Late).
Every considered fixture lands in recommendations.csv with RECOMMENDATION 0/1 and RESULT left for manual grading in the admin UI.
Scraping a site that will not sit still
The research/ tree is a lab notebook trail:
- Compare tools (
requests, BS4, lxml, Selenium) instead of marrying the first one. - Read someone else’s scraper (scrapeOP) line by line before writing mine.
- Learn that click-only scrapers die when CSS changes; full reload per click is too slow.
- Settle on build the OddsPortal URL, open it, parse the DOM, with up to 5 retries when the bookmaker table is empty.
- Dismiss ad overlays that hide the table (
reject_ads).
OddsPortal URLs are slug-shaped:
https://www.oddsportal.com/{sport}/{country}/{league}/{match}/#{bet};{period}
Handicap/total lines append ;{limit:.2f};0 when needed.
Later deploys dropped bundled chromedriver binaries for ChromeDriverManager so Docker did not need a perfect pin on every Chrome bump.
Messy text to structured data
Source tips are line-based (soccer,, basketball,, …). Corner markets we deliberately ignored.
link_inputs.py pulls sport, country, league, teams (or a subscribe placeholder we flag as missing), period, bet type, optional numeric line, and old/new prices. One Telegram post can hold several tips; split_with_exclusion splits on blank lines but keeps the blank line before " Odds" so we do not chop multi-tip posts wrong.
Two sites do not share vocabulary, so we maintained dictionaries:
| Layer | Example job |
|---|---|
| Sport | soccer -> football |
| Country | display name -> URL slug |
| League | league_mapping.json (source channel league name -> one or more OddsPortal slugs) |
| Bet type | 3-way -> 1x2, Asian handicap -> ah, totals -> over-under |
| Period | full time / 1st half -> OddsPortal fragment |
Statistics notebooks counted which leagues actually appeared in history so we knew where manual mapping was worth the pain. When several slugs could fit, we open each league page and score team names; zero score means log, do not post.
Telegram, three ways
They are not interchangeable:
| Library | Acts as | Used for |
|---|---|---|
| Telethon | Your user account | Read a channel you joined (api_id, api_hash, session string in Docker so nobody types a login code on the server) |
| Bot HTTP API | Tip bot | Fire the finished post (sendMessage) |
| python-telegram-bot 13.7 | Registration bot | ConversationHandler, keyboards, contact button, ban |
Ops notes baked into the repo: Telethon 1.28 tripped asyncio.CancelledError for us, so we pinned 1.23. Notebooks needed nest_asyncio around Telethon’s event loop.
Subscribers
Registration is a multi-step conversation: phone (contact button), sex, birth year, country (fuzzy pycountry + Cyrillic names transliterated to Latin), email (email-validator), then write user_data.json and set subscription dates to end-of-month.
Tiers (FREE / STARTER / GROWTH) were sketched on a chart in research; in the running system money was a field you typed, not a payment gateway. Access control was Telegram ban.
The kicker runs around midnight: if subscription_end_date is today, DM a renew reminder; if it is in the past, ban_chat_member on the tips channel. Logger counts successes and failures in the production copy.
user_blacklist.json stops known bad actors at /start.
Admin site and deployment
Tips is ASP.NET Core 6, Blazor Server, MudBlazor: tables for recommendations (inline edit, CSV download), users, and the parsed logger. FileService reads the same JSON/CSV the Python workers write - no SQL database.
Logging on purpose is pipe-delimited fixed columns (COMMENT, sport, odds, flags, …) so Blazor can tabulate without a logging DB. The fragility is real: a | inside a value or a column added only in Python breaks a row. We proved log2json() in a notebook before wiring it into core.py.
Deployment evolution:
- Early: one Dockerfile (Python 3.7 + Chrome),
docker-composeruns recommender loop + registration on a shared volume. - Later: four services (
recommender,register,kicker,website) plus Traefik (HTTP/HTTPS, Let’s Encrypt) on a small cloud server. All mount the sameshared_data->/rapidtipster/data.
Illustrative layout (no hostnames or secrets):
services:
recommender: # python -m ...app.core
register:
kicker:
website: # ASPNETCORE_URLS=http://+:80
traefik: # :80 / :443, ACME volume
rt-test is a parallel tree: localhost Docker, different bot and channel, README says do not merge with production - the pattern I wish every side project had from day one.
Public face: Facebook page and Instagram @rapidtipster (optional socials from the old README).
What broke in production
Real incidents, not hypothetical:
- Empty channel text: Telethon still returned message IDs, but the body was blank - the scraper looked healthy while the payload vanished. We documented the debugging path (library version, session, “maybe the channel hides text now”).
- Mapping debt: leagues and rare bet types forever stuck in WIP JSON; notebooks list what was still manual.
- Three copies:
lalebet_product,rapidtipster,rt-test- a fix in one was not automatic in the others. - Results:
RESULTin CSV is hand-edited after the match; nothing in Python auto-graded bets. - Secrets: API ids, bot tokens, and session strings were still hardcoded in places - they belonged in env vars. This page does not repeat them.
- Kicker scheduling: midnight job wired as “seconds until next midnight” once; rescheduling the following night was easy to get wrong.
We stopped the service after a run with real subscribers - not because the idea was untested, but because ops + partner time + source-channel risk added up.
What I learned
- Product thinking: idempotent loops, explicit skip lists, shared files as the database, a test stack that does not touch live subscribers.
- Separate rule from plumbing: the 0.85 ratio is one function; fetching two numbers from two websites is everything else.
- Second language for the UI: Python stayed the worker; C# was the screen I trusted for edits and downloads.
- Shipping beats perfection: static HTML admin -> Blazor; bundled chromedriver -> manager; two-container compose -> Traefik fleet.
Domain-wise this sat next to my WIN.gg years - same industry, opposite end of the stack (consumer tips vs B2B models). Here the metric was “did the tip still have edge when we checked the board?”, not ROC-AUC.
If something is wrong, too rosy, or you want the end date spelled out, tell me.