Miloš Vlainić

My GitHub blog: things you might be interested, and probably not...

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:

  1. Read pending messages.
  2. Build an OddsPortal URL when the bet type is known.
  3. Skip known bad cases (unknown league, no match on the page, zero fuzzy score).
  4. Collect odds; do not recommend the same fixture twice (collected_matches.json).
  5. Fetch again so the next cycle is fresh.
  6. Turn the text log into logger.json for 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)

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:

  1. Compare tools (requests, BS4, lxml, Selenium) instead of marrying the first one.
  2. Read someone else’s scraper (scrapeOP) line by line before writing mine.
  3. Learn that click-only scrapers die when CSS changes; full reload per click is too slow.
  4. Settle on build the OddsPortal URL, open it, parse the DOM, with up to 5 retries when the bookmaker table is empty.
  5. 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:

  1. Early: one Dockerfile (Python 3.7 + Chrome), docker-compose runs recommender loop + registration on a shared volume.
  2. Later: four services (recommender, register, kicker, website) plus Traefik (HTTP/HTTPS, Let’s Encrypt) on a small cloud server. All mount the same shared_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:

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

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.