Skip to main content

slop-writer

A Claude Code skill that analyzes a Telegram channel:

  • Scrape posts (text, media, reactions, views, forwards, tags) and the comment threads under each.
  • Track outward forwarders — outside channels that re-share your posts — and inward citations — channels you forwarded from.
  • Build an append-only time-series of per-post metrics on every re-run, so you can watch engagement evolve.
  • Pull subscriber growth/churn broken down by acquisition source and views by hour of day for the "best time to post" question.
  • Schedule, retime, and rewrite future posts — the one write path.

Backed by Telethon, with a separate read-only SQL CLI for querying the local SQLite DB (one file per channel).

This is my personal skill — I built it to manage my own channel, @fastnewsdev. It's shared here in case the patterns are useful to someone else running a Telegram channel

Renamed from tg-analytic-skill. The analytics are being repackaged as a PyPI distribution driving an MCP server, and the new name leaves room for media beyond Telegram. Nothing has moved yet — the skill below works exactly as before, and links to the old repository path still redirect.

Install

From any project where you want the skill available to Claude Code, use the skills CLI:

npx skills@latest add Lancetnik/slop-writer

First-run setup

Run /setup-tg-analytic in Claude Code, once per project. It asks for your Telegram API credentials (create them here), writes .tg-analytic/.env, and walks you through the one-time login — which you run in your own terminal, since Telethon prompts for the SMS code and 2FA password on stdin:

SKILL=.claude/skills/tg-analytic-skill   # adjust to your install
uv run "$SKILL/scripts/tg_scrape.py" login

That writes .tg-analytic/session.session; every later command reuses it.

All runtime state — .env, the session, per-channel *.db files, downloaded media — lives in .tg-analytic/ at your project root (the directory you run commands from), never inside the skill. Keep it out of git: the session file is a live login to your Telegram account.

Usage

Inside Claude Code, ask in plain language:

Analyze @some_channel — show me the most popular posts. Who's forwarding @some_channel? Which channels do they cite most often? Refresh metrics on the last 20 posts of @some_channel. How did the discussion group grow after Tuesday's post? Schedule this draft for Friday at 18:00.

The skill picks the command, runs it from the project root, and pastes back the Markdown summary each command prints (top posts by views and reactions, top tags, outward forwarders and inward citations with their post ids) — usually the answer is right there without dropping into SQL.

Keeping the metric history usable

post_metrics is a time series, but only of the moments you actually scraped — it cannot be backfilled. A routine scrape --latest N re-measures recent posts only, so an older post can sit on the single snapshot it got on its first day forever, and any "how did this post do over time" question then has nothing to answer from. Every so often, run fetch over a spread of older ids as well:

uv run "$SKILL/scripts/tg_scrape.py" fetch --channel @yourchannel 340 345 350 355

Views in particular keep climbing for months, so a post's snapshots are worth collecting long after it stops feeling current.

To drive the CLIs by hand, the full command reference lives in the skill:

Repository layout

skills/
  tg-analytic-skill/
    SKILL.md          Skill instructions: the branch map, not the flags.
    scripts/
      tg_scrape.py           Telethon read CLI (scrape, fetch, group, subscribers, views, scheduled).
      tg_publish.py          Telethon write CLI (schedule, reschedule, edit).
      tg_query.py            Read-only SQL CLI.
    references/
      scraping.md     tg_scrape.py commands and selection flags.
      querying.md     tg_query.py usage and search patterns.
      publishing.md   tg_publish.py commands and scheduling rules.
      schema.md       DB schema reference for writing SQL.
      markup.md       Supported Markdown -> Telegram markup for tg_publish.
  setup-tg-analytic/
    SKILL.md          One-time credential + login setup, run by the user.
src/
  slop_writer/        The library the CLIs import, published to PyPI. The three
                      scripts above declare `slop-writer` in their PEP-723
                      headers, so `uv run` fetches it — nothing is vendored
                      into the skill directory.
    db.py             DB schema (source of truth), paths, open helpers. Stdlib only.
    tg.py             Telethon session/credential plumbing.
    render.py         Markdown renderers for the per-command summaries.
    markdown.py       Markdown -> Telethon MessageEntity (tg_publish).
    group.py          Discussion-group classification helpers. Stdlib only.
tools/
  check_schema_doc.py  Dev-only: guard SCHEMA <-> references/schema.md drift (not
                       shipped). Pinned to this checkout, not to the released
                       package, so it guards the working tree.

Runtime state (.env, the Telethon session, per-channel *.db files, media) lives in a gitignored .tg-analytic/ directory at the root of whatever project you run the skill from — nothing is written inside the skill itself.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

slop_writer-0.1.0.tar.gz (24.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

slop_writer-0.1.0-py3-none-any.whl (26.6 kB view details)

Uploaded Python 3

File details

Details for the file slop_writer-0.1.0.tar.gz.

File metadata

  • Download URL: slop_writer-0.1.0.tar.gz
  • Upload date:
  • Size: 24.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for slop_writer-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bf5824122c7a609c2533b6007082581ab29d5175fade78bc72f30e18d190fc33
MD5 86debb0ce66884e1ffcdd65ba97902f2
BLAKE2b-256 12e448a8635a8b171aa3c5d36d87e69d13c6c22dc167758a1db71cabd4ca8dbe

See more details on using hashes here.

Provenance

The following attestation bundles were made for slop_writer-0.1.0.tar.gz:

Publisher: publish.yaml on Lancetnik/slop-writer

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file slop_writer-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: slop_writer-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 26.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for slop_writer-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 65d7c359c44bc5919d91908244b2e2be4f509cfcc22e56de048457cd17f42202
MD5 75e374bbe0fe6418c5886465644ce1bd
BLAKE2b-256 b273402946630c130a44698cfb8c079dda997f473c1a5d2a9a163dc4c5573a00

See more details on using hashes here.

Provenance

The following attestation bundles were made for slop_writer-0.1.0-py3-none-any.whl:

Publisher: publish.yaml on Lancetnik/slop-writer

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.4.3

2 files

0.4.2

2 files

0.4.1

2 files

0.4.0

2 files

0.2.0

2 files

This release

0.1.0 This release

2 files

0.0.1

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page