This workspace now includes two scripts:
serie_a_bluesky_tool.py: end-to-end workflow for Serie A fixtures, AI picks, your pick, Bluesky posting, and next-day scoring.bets_tracker.py: simple local bet tracker created earlier.
- Fetches Serie A fixtures for
todayortomorrow. - For each match asks:
- ChatGPT (OpenAI API)
- Claude (Anthropic API)
- Gemini (Google API)
- Prompts you for your own pick (
HOME,DRAW,AWAY). - Posts your pick as a Bluesky post.
- Posts AI picks as a reply to your post.
- Saves thread metadata in
data/posted_picks.json. - Later, posts one daily scoreboard reply for tracked picks (
scorecommand).
- Python 3.10+
Third-party Python package for X posting:
tweepy(required only when using--platform xor--platform both)
Install it with:
python3 -m pip install tweepySet these before running publish or score.
For a system-wide setup on macOS with zsh, add them to ~/.zshrc, then reload your shell with source ~/.zshrc:
export OPENAI_API_KEY="..."
export ANTHROPIC_API_KEY="..."
export GEMINI_API_KEY="..."
export BSKY_HANDLE="your-handle.bsky.social"
export BSKY_APP_PASSWORD="xxxx-xxxx-xxxx-xxxx"
export X_CONSUMER_KEY="..."
export X_CONSUMER_SECRET="..."
export X_ACCESS_TOKEN="..."
export X_ACCESS_TOKEN_SECRET="..."
export X_HANDLE="your_x_handle"To verify they are available in new terminals:
printenv OPENAI_API_KEY
printenv ANTHROPIC_API_KEY
printenv GEMINI_API_KEY
printenv BSKY_HANDLE
printenv X_CONSUMER_KEY
printenv X_ACCESS_TOKENX variable notes:
X_CONSUMER_KEY,X_CONSUMER_SECRET,X_ACCESS_TOKEN, andX_ACCESS_TOKEN_SECRETare required for X posting.X_HANDLEis optional and is only used to print friendly tweet URLs in command output.- If you run Bluesky-only (
--platform bluesky), X variables are not required.
Optional model overrides:
export OPENAI_MODEL="gpt-4.1-mini"
export ANTHROPIC_MODEL="claude-sonnet-4-6"
export GEMINI_MODEL="gemini-2.5-flash"python3 serie_a_bluesky_tool.py fixtures --day today
python3 serie_a_bluesky_tool.py fixtures --day tomorrowpython3 serie_a_bluesky_tool.py publish --day today
python3 serie_a_bluesky_tool.py publish --day yesterdaySelect posting platform:
# Bluesky only
python3 serie_a_bluesky_tool.py publish --day today --platform bluesky
# X only
python3 serie_a_bluesky_tool.py publish --day today --platform x
# Both (default)
python3 serie_a_bluesky_tool.py publish --day today --platform bothOptional session filter (local kickoff time):
# All fixtures for the day (default)
python3 serie_a_bluesky_tool.py publish --day tomorrow --session all
# Morning fixtures only (before 12:00 local)
python3 serie_a_bluesky_tool.py publish --day tomorrow --session morning
# Afternoon fixtures only (12:00 local and later)
python3 serie_a_bluesky_tool.py publish --day tomorrow --session afternoonTest mode (no posting):
python3 serie_a_bluesky_tool.py publish --day today --dry-runThe command will:
- show AI picks in terminal,
- ask for your pick per match,
- create thread posts on the selected platform(s),
- persist tracking data to
data/posted_picks.json. - cache AI provider responses in
data/ai_pick_cache.jsonfor reuse on repeated test runs.
With --dry-run, it prints post previews and still records generated picks in data/posted_picks.json, but does not create posts.
With --platform x or --platform both, publish creates an X root post and then an X AI reply to that root.
If any of the three AI providers fails to return a pick for any fixture, publish aborts before prompting you for picks and before creating any posts, so you do not end up with partial AI coverage.
By default, publish uses cached AI picks for the same fixture/day/provider/model to avoid extra token usage during testing. Use --no-cache to force fresh API calls:
python3 serie_a_bluesky_tool.py publish --day today --dry-run --no-cacheUse --test-mode for isolated testing runs:
python3 serie_a_bluesky_tool.py publish --day today --dry-run --test-modeIn publish --test-mode:
- cache is fully disabled (no cache reads, no cache writes), and
- tracking rows created by the run are tagged as test data (
"test_mode": true).
To run non-interactively, provide your picks in a text file.
You can use fully free-form text with no structure (one non-empty line per fixture, in the same order shown by fixtures):
I like Cagliari at home, thin edge.
Inter to win, better squad and form.
Juventus should control this matchup.
You can also use keyed lines if you prefer:
# key can be fixture id, or "Home vs Away"
100=HOME
Lazio vs Internazionale=AWAY
Then run:
For automatic scoring of your picks, include a [PICKS] section with explicit pick codes (1X2 or totals):
My picks for today:
I like Napoli at home, their form is strong.
Bologna has been playing well away recently.
[PICKS]
Napoli vs Bologna = HOME
Juventus vs Roma = AWAY
Inter vs Milan = OVER 2.5
Lazio vs Torino = UNDER 1,1.5
[/PICKS]
The [PICKS] section is automatically removed from the Bluesky post (only the narrative text above it is posted), but the structured picks are extracted and used for automatic scoring.
Supported structured pick formats:
- 1X2:
HOME,DRAW,AWAY - Totals whole line:
OVER X,UNDER X - Totals half line:
OVER X.5,UNDER X.5 - Totals split line:
OVER X,X.5,UNDER X,X.5,OVER X.5,X+1,UNDER X.5,X+1
Examples:
Cagliari vs Udinese = UNDER 1
Roma vs Lazio = OVER 2.5
Como vs Parma = OVER 1,1.5
Genoa vs Milan = UNDER 1.5,2
Use the committed template file to bootstrap your local picks file once:
cp data/my_picks.example.txt data/my_picks.txtdata/my_picks.txt is intended for local use and is git-ignored.
Then run:
python3 serie_a_bluesky_tool.py publish --day today --dry-run --picks-file data/my_picks.txtFor high-volume days, you can keep one file and split narrative and picks into session blocks:
[MORNING]
Morning narrative text...
[PICKS]
Inter vs Milan = HOME
Juventus vs Roma = AWAY
Napoli vs Lazio = OVER 2.5
Atalanta vs Fiorentina = UNDER 1.5,2
[/PICKS]
[/MORNING]
[AFTERNOON]
Afternoon narrative text...
[PICKS]
Napoli vs Lazio = HOME
Atalanta vs Fiorentina = DRAW
[/PICKS]
[/AFTERNOON]
When blocks are present, use --session morning or --session afternoon to choose the block.
When blocks are not present, the file continues to work exactly as before.
If any fixture for that day is missing from the file, publish aborts before posting.
When --picks-file is used, publish creates:
- one root post containing the full text contents of
my_picks.txt, and - one single reply to that root containing all ChatGPT/Claude/Gemini picks for the day's fixtures.
When your picks-file text is not a supported structured pick value in [PICKS], it is posted as-is on Bluesky and your personal pick is marked as unavailable for automatic result scoring.
AI reply previews/posts are shown with human-readable pick text (for example, Napoli to win, Draw) rather than only 1X2 codes.
Note on scoring: If you include a [PICKS] section with explicit structured picks (1X2 and/or totals), your picks will be automatically scored when you run score after the matches finish. If you don't include a [PICKS] section, your freeform picks text is posted as-is on Bluesky, but automatic scoring is not available for your picks.
python3 serie_a_bluesky_tool.py score --day yesterdaySelect posting platform:
# Bluesky only
python3 serie_a_bluesky_tool.py score --day yesterday --platform bluesky
# X only
python3 serie_a_bluesky_tool.py score --day yesterday --platform x
# Both (default)
python3 serie_a_bluesky_tool.py score --day yesterday --platform bothOptional session filter (same definitions as publish):
python3 serie_a_bluesky_tool.py score --day tomorrow --session morning
python3 serie_a_bluesky_tool.py score --day tomorrow --session afternoonTest mode (no posting):
python3 serie_a_bluesky_tool.py score --day yesterday --dry-runTo score only test runs, add --test-mode:
python3 serie_a_bluesky_tool.py score --day yesterday --dry-run --test-modeTo simulate hypothetical outcomes in test mode, provide a JSON file with fixture score overrides:
python3 serie_a_bluesky_tool.py score --day yesterday --dry-run --test-mode --sim-results-file data/sim_results.jsondata/sim_results.json supports either format. You can identify fixtures by either fixture_id or user-friendly matchup text (Home vs Away):
{
"Inter vs Milan": {"home_score": 2, "away_score": 1},
"Napoli vs Lazio": {"home_score": 0, "away_score": 0}
}or:
[
{"matchup": "Inter vs Milan", "home_score": 2, "away_score": 1},
{"fixture_id": "401547124", "home_score": 0, "away_score": 0}
]Safety guardrails: --sim-results-file is only accepted when both --test-mode and --dry-run are enabled.
When all tracked fixtures for that day are final, score posts one scoreboard reply to the existing thread, ordered as Minvest, Gemini, Claude, ChatGPT.
For both Bluesky and X, the scoreboard reply is posted as a reply to the AI picks reply (not directly to the root post).
With --dry-run, it prints the scoreboard preview without posting and without marking tracked picks as scored.
score behavior with test mode:
- default (
--test-modenot set): ignores test-tagged tracking rows, - with
--test-mode: scores only test-tagged tracking rows.
- Structured picks in
[PICKS]support 1X2 and totals (including split/quarter lines). - Fixture feed source is ESPN Serie A scoreboard API.
- Bluesky posts are capped to 300 characters.
The original local tracker is still available:
python3 bets_tracker.py --helpRun unit tests with:
python3 -m unittest discover -s tests -p "test_*.py" -vUse test_posting.py to run a mocked publish flow and quickly verify posting behavior for Bluesky and/or X.
What it does:
- Mocks fixtures and AI picks.
- Runs one publish cycle through
serie_a_bluesky_tool.py. - Supports dry-run previews and live posting.
- Adds a unique timestamp suffix by default to avoid duplicate-post rejection on repeated X test runs.
Examples:
# Dry-run to X only
python3 test_posting.py --platform x --dry-run
# Live post to X only
python3 test_posting.py --platform x
# Live post to both platforms
python3 test_posting.py --platform both
# Force a custom uniqueness suffix
python3 test_posting.py --platform x --suffix smoke-test-1Options:
--platform:bluesky,x, orboth(default:both).--dry-run: preview mode; no posts are created.--suffix: optional text appended into mocked fixture content to guarantee unique post text.
Environment variables:
- For
--platform bluesky: setBSKY_HANDLEandBSKY_APP_PASSWORD. - For
--platform x: setX_CONSUMER_KEY,X_CONSUMER_SECRET,X_ACCESS_TOKEN,X_ACCESS_TOKEN_SECRET.