Skip to main content

微信公众号命令行工具

Project description

mp-cli 微信公众号命令行工具

一个用于管理微信公众号的命令行工具,支持文章草稿、素材上传、发布管理、用户管理等功能。

AI Agent 接入文档: 详见 AGENT.md

安装

# 克隆源码
git clone https://github.com/your-username/mp-cli.git
cd mp-cli

# 安装
pip install .

安装后即可使用 mp 命令。

配置

设置环境变量:

export WECHAT_APPID=your_appid
export WECHAT_APPSECRET=your_appsecret

或复制 .env.example.env 并填入你的配置:

cp .env.example .env

使用

Token 管理

# 获取 access_token
mp token get

# 清除缓存的 token
mp token clear

草稿管理

# 查看草稿列表
mp draft list

# 查看草稿内容
mp draft get <media_id>

# 删除草稿
mp draft delete <media_id>

素材管理

# 上传素材
mp media upload <file_path> --type image

# 上传图片获取 URL
mp media upload-image <file_path>

# 查看素材列表
mp media list image

# 删除素材
mp media delete <media_id>

发布管理

# 提交草稿发布
mp publish submit <media_id>

# 查询发布状态
mp publish status <publish_id>

# 查看发布记录
mp publish list

# 删除发布内容
mp publish delete <publish_id>

用户管理

# 获取关注者列表
mp user list

# 获取用户信息
mp user info <openid>

# 批量获取用户信息
mp user batch-get <openid1> <openid2> ...

# 设置用户备注
mp user update-remark <openid> <remark>

# 获取标签列表
mp user tag-list

# 创建标签
mp user create-tag <tag_name>

# 删除标签
mp user delete-tag <tag_id>

菜单管理

# 获取当前菜单
mp menu get

# 创建菜单 (从 JSON 文件)
mp menu create menu.json

# 删除菜单
mp menu delete

模板消息

# 获取模板列表
mp template list

# 发送模板消息
mp template send <openid> <template_id> '{"first":{"value":"xxx"}}'

# 删除模板
mp template delete <template_id>

自动回复

# 获取所有自动回复规则
mp reply get-all

# 添加文本自动回复
mp reply add-text --keyword "关键词" "回复内容"

# 添加图文自动回复
mp reply add-news --keyword "关键词" "标题" "摘要" "链接" "图片URL"

命令帮助

查看所有命令:

mp --help

查看某个子命令的帮助:

mp <command> --help

示例

上传并发布文章

# 1. 上传图片素材
mp media upload article.jpg --type image --permanent

# 2. 创建草稿 (需要调用 API 或使用其他工具)

# 3. 提交发布
mp publish submit <media_id>

# 4. 查看发布状态
mp publish status <publish_id>

管理用户标签

# 1. 查看现有标签
mp user tag-list

# 2. 创建新标签
mp user create-tag "活跃用户"

# 3. 查看用户信息
mp user info <openid>

许可证

MIT License

Project details


Download files

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

Source Distribution

wechat_mp_cli-0.1.0.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

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

wechat_mp_cli-0.1.0-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: wechat_mp_cli-0.1.0.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.9

File hashes

Hashes for wechat_mp_cli-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0f3f51368ca3d196d701b0b6fab28e66636a1026fe16ffba34cb15f190b344d1
MD5 c4e499984fd3ad960e2d1542cab58fc3
BLAKE2b-256 7de5c91d6ccb05555cf32b2fa86155095464092411783cb2d5f12f73e2469f4f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: wechat_mp_cli-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.9

File hashes

Hashes for wechat_mp_cli-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8063b22c4ff6e5c1a7728919e7d936e597f29e3184c77de6f624682278c0ad4c
MD5 1eb4dbbb6932be70fc6ddf5abc62f6b7
BLAKE2b-256 01714e0f77221d708142ad20d1043ed4a508c13da33eb207011ee20ec2a71932

See more details on using hashes here.

Supported by

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