mirror of
https://github.com/jackwener/OpenCLI.git
synced 2026-09-14 18:25:42 +08:00
76a9c78261
* feat(weibo): add delete command to remove user's own posts
Adds `opencli weibo delete <id>` so the same workflow that creates a
post can also remove one without leaving the CLI. The id positional
accepts either the numeric `idstr` (e.g. `5299336218674412`) or the
base62 `mblogid` (e.g. `QFGbHAoBS`) found in any weibo URL or in the
output of `weibo me` / `weibo feed` / `weibo post`.
Implementation lives in a single `page.evaluate` IIFE so cookies +
the XSRF-TOKEN double-submit token stay first-party:
1. Resolve mblogid / idstr via `GET /ajax/statuses/show?id=<input>`,
which returns the canonical `idstr`. Empty result -> 404 path.
2. Read the `XSRF-TOKEN` cookie via `document.cookie`.
3. `POST /ajax/statuses/destroy` with `id=<idstr>` body and the
`X-Xsrf-Token` header.
4. Return `[{ status: 'deleted', id, mblogid }]`.
Typed errors:
- 401 / 403 from either show or destroy -> `AuthRequiredError`
- `show` returning no `idstr` -> `EmptyResultError`
- Non-2xx HTTP on either call -> `CommandExecutionError` with status
- API response `ok !== 1` -> `CommandExecutionError` with the API msg
Closes #1619.
Verified live on macOS / opencli v1.7.22, weibo cookie session:
- Deleted the lingering test post from #1602 verification
(idstr=5299336218674412, mblogid=QFGbHAoBS):
`weibo delete QFGbHAoBS` returned
`[{ status: 'deleted', id: '5299336218674412', mblogid: 'QFGbHAoBS' }]`
- `weibo me` shows `statuses: 3` (was 4 before the delete)
- `weibo post QFGbHAoBS` now throws "Post not found"
Unit tests: 8 / 8 in `clis/weibo/delete.test.js` (happy path,
empty-id, auth, not-found, show-http, destroy-http, api-msg, envelope
unwrap). Full weibo suite: 38 / 38 pass.
* fix(weibo): require delete postcondition evidence
---------
Co-authored-by: jackwener <jakevingoo@gmail.com>
2.0 KiB
2.0 KiB
Weibo (微博)
Mode: 🔐 Browser · Domain: weibo.com
Commands
| Command | Description |
|---|---|
opencli weibo hot |
微博热搜 |
opencli weibo search |
Search Weibo posts by keyword |
opencli weibo feed |
首页时间线(for-you / following) |
opencli weibo user |
用户信息 |
opencli weibo user-posts |
按用户列出微博,可选日期范围 |
opencli weibo me |
我的信息 |
opencli weibo post |
读取单条微博 |
opencli weibo favorites |
我的微博收藏列表 |
opencli weibo publish |
通过网页 UI 直接发布微博,支持最多 9 张图片 |
opencli weibo delete |
删除登录账号自己的单条微博 |
opencli weibo comments |
微博评论 |
Usage Examples
# Quick start
opencli weibo hot --limit 5
# JSON output
opencli weibo hot -f json
# Search
opencli weibo search "OpenAI" --limit 5
# Home timeline (default: for-you / 推荐流)
opencli weibo feed --limit 10
# Following-only timeline (strict chronological following feed)
opencli weibo feed --type following --limit 10
# Read a post from feed/search using the emitted id
opencli weibo post <id>
# List a user's posts by uid or screen name
opencli weibo user-posts 1670458304 --start 2025-06-01 --end 2025-06-02 --limit 20
# Verbose mode
opencli weibo hot -v
# Favorites
opencli weibo favorites --limit 20
# Publish text (executes immediately)
opencli weibo publish "Hello from OpenCLI"
# Publish text with images (executes immediately)
opencli weibo publish "Hello with images" --images /path/a.jpg,/path/b.png
# Delete one of your own posts (executes immediately)
opencli weibo delete <id>
Listing Columns
feed, search, and user-posts expose id for post rows. Pass that value
directly to opencli weibo post <id>. hot rows are search topics, not post
rows.
Prerequisites
- Chrome running and logged into weibo.com
- Browser Bridge extension installed