Skip to main content

ChatECNU

ChatECNU 是 ECNU 门户与校园网联网工具包。安装包名仍是 ChatECNU,日常命令主推 ecnu。 chatecnu 安装命令作为兼容别名保留;两个入口共享同一 Click 对象,命令树固定以规范名 ecnu 为根。

文档入口

任务 链接
安装和最小验证 https://arch.gh.wzhecnu.cn/ChatECNU/quickstart/
命令树 https://arch.gh.wzhecnu.cn/ChatECNU/cli-tree/
ChatEnv 变量 https://arch.gh.wzhecnu.cn/ChatECNU/chatenv/
ECNU 使用 https://arch.gh.wzhecnu.cn/ChatECNU/ecnu/

安装

pip install ChatECNU

如需验证码识别能力:

pip install "ChatECNU[captcha]"

显式准备校园网工具

pip install 不会改用户文件。默认 Python 后端无需安装 auth_client;下面的显式离线安装器只准备 Linux x86_64 binary 兼容后端:

ecnu net install --dry-run --json
ecnu net install --json
# 只更新指定 ChatEnv profile,不激活它:
ecnu -e campus net install --json
# 新配置可定制认证端点;不要传账号、密码或 token:
ecnu net install --host login.ecnu.edu.cn --ac-id 1 --campus-url "" --campus-postfix ""

实体默认在 $CHATARCH_HOME/chatecnu/(未设置时 ~/.chatarch/chatecnu/):bin/auth_client、config/auth-setting.toml;兼容入口为 ~/.local/bin/auth_client、~/.auth-setting 薄链接。既有可用 legacy 文件会原样保留并被选用,不迁移、不覆盖;重复安装不重写。端点选项只影响新生成的设置;修改既有设置须显式 --force。替换前原文件/链接备份到 chatecnu/backups/<id>/,未知链接目标不修改;目录冲突始终失败。

--dry-run 连目录和 ChatEnv profile 都不创建;--json 回读路径、来源与动作,不输出 profile 值。只通过 EnvStore 更新 ECNU_AUTH_CLIENT / ECNU_AUTH_SETTING_FILE,保留凭据和其他值。安装器不登录、不重启、不安装 daemon、无下载;Mac、Windows、Linux ARM 在写入前失败(包括 dry-run)。

命令结构

ChatECNU 的命令面可用 ecnu --tree 从当前 Click 注册表直接回读,默认包含参数签名;ecnu --tree-brief 保留命令节点和说明,但省略参数签名:

ecnu
├── --help  # Show this message and exit.
├── --version  # Show the version and exit.
├── --tree  # Print the registered CLI tree and exit.
├── --tree-brief  # Print the registered CLI tree without parameter signatures and exit.
├── --env ENV-PROFILE  # ChatEnv 配置名。
├── home  # ECNU 门户。
│   ├── info [--json]  # 门户首页摘要。
│   ├── login [--username USERNAME] [--password PASSWORD] [--sms-code SMS-CODE] [--json] [--interactive]  # 登录门户。
│   ├── logout [--json]  # 退出门户会话。
│   ├── status [--json]  # 门户会话状态。
│   └── user [--json]  # 门户用户信息。
├── net  # 校园网联网。
│   ├── check [--interface INTERFACE] [--auth-client AUTH-CLIENT-PATH] [--setting-file SETTING-FILE] [--json]  # 检查在线状态。
│   ├── ensure-login [--interface INTERFACE] [--install-service] [--uninstall-service] [--service-status] [--save-password] [--interval INTERVAL] [--probe-url PROBE-URL] [--dry-run] [--auth-client AUTH-CLIENT-PATH] [--setting-file SETTING-FILE] [--username USERNAME] [--password PASSWORD] [--allow-argv-password] [--json] [--interactive]  # 离线时登录。
│   ├── install [--host HOST] [--ac-id AC-ID] [--campus-url CAMPUS-URL] [--campus-postfix CAMPUS-POSTFIX] [--force] [--dry-run] [--json]  # 离线准备联网工具与设置,不登录。
│   ├── login [--interface INTERFACE] [--auth-client AUTH-CLIENT-PATH] [--setting-file SETTING-FILE] [--username USERNAME] [--password PASSWORD] [--allow-argv-password] [--json] [--interactive]  # 登录。
│   └── logout [--interface INTERFACE] [--auth-client AUTH-CLIENT-PATH] [--setting-file SETTING-FILE] [--username USERNAME] [--json] [--interactive]  # 退出校园网。
└── visitor  # 访客账号。
    ├── create [--remark REMARK] [--dry-run] [--json] [--interactive]  # 创建访客账号。
    ├── default [--password1 PASSWORD1] [--password2 PASSWORD2] [--remark REMARK] [--json] [--interactive]  # 维护默认访客账号。
    ├── delete [--id VISITOR-ID] [--dry-run] [--json] [--interactive]  # 删除访客账号。
    ├── get [--id VISITOR-ID] [--account ACCOUNT] [--json]  # 查询访客账号。
    ├── list [--json]  # 列出访客账号。
    └── update [--id VISITOR-ID] [--remark REMARK] [--password PASSWORD] [--dry-run] [--json] [--interactive]  # 更新访客备注和密码。

门户命令统一放在 home 下:

ecnu home login -i
ecnu home info
ecnu home status
ecnu home user
ecnu home logout

门户会话默认写入 ChatEnv runtime token-store:~/.chatarch/tokens/ECNU/<profile>.json;ecnu home status --json 只回读安全摘要,不输出原始 Cookie/CSRF。chatenv token refresh ECNU <profile> 可从同名 stable env profile 发起非交互 OCR 自动登录并由 ChatEnv 写入 runtime token-store;遇到短信验证码或验证码候选失败时会安全失败。

校园网联网统一放在 net 下:

ecnu net check --json
ecnu net login -I
ecnu net logout -I
ecnu net ensure-login -I

默认 ECNU_NETWORK_BACKEND=python:直接执行 SRun HTTP 协议,不运行 auth_client,不通过外部进程 argv 传密码。复用 ChatEnv 的 ECNU_USERNAME / ECNU_PASSWORD 及原生 ECNU_NETWORK_BASE_URL / ECNU_NETWORK_AC_ID;Python 仅在显式 --setting-file 时导入旧格式;登录/退出后重新检查实际在线状态,JSON 返回 backend=python。只有显式选择 ECNU_NETWORK_BACKEND=binary 才使用旧二进制,且登录仍需 --allow-argv-password;--auth-client / ECNU_AUTH_CLIENT 也仅作用于 binary。默认 Python 路径不需要 net install。

敏感值(密码、Cookie、短信码、会话)不要打印或提交。

macOS 定时自动重登

自动重登属于现有 ecnu net ensure-login(兼容入口 chatecnu net ensure-login),无需额外 CLI。

# 只预览,不写配置或启动任务
ecnu net ensure-login --interface en1 --install-service --interval 60 --dry-run --json
# 安装并启动当前用户 LaunchAgent
ecnu net ensure-login --interface en1 --install-service --interval 60
# 隐藏输入当前服务账号密码,保存到 macOS 钥匙串
ecnu net ensure-login --save-password
# 查看服务与最近一次检测结果
ecnu net ensure-login --service-status --json
# 停止并卸载任务,保留配置、状态和钥匙串凭据
ecnu net ensure-login --uninstall-service

--interface 也支持 net check/login/logout,当前仅支持 macOS Python 后端。 ecnu net check --interface en1 --json 查询 Wi-Fi,ecnu net check --interface en0 --json 单独查询网线。DNS、外网检测及认证连接均绑定所选网卡,保持 HTTPS 证书验证;不回退到其他网卡或代理, 不修改系统路由和网络优先级。--probe-url 默认 https://www.baidu.com/,采用 HTTPS 检测,不依赖 ICMP ping。

服务在用户登录后及每隔 --interval 秒(默认 60)运行一次,直接调用安装包 python -m chatecnu net ensure-login。它绑定安装时识别的路由器地址和 MAC;其他网络跳过登录。 只有连续两次外网检测失败且校园网明确返回未认证才尝试登录;未知认证状态、已经认证但外网故障、 缺少或锁定的凭据均不会盲目重登。重试间隔至少五分钟;检测加锁以防并发。

凭据从 -e campus 指定的 ChatEnv profile 的 ECNU_USERNAME / ECNU_PASSWORD 加载, 账号必须匹配服务配置;否则读取 macOS 登录钥匙串。--save-password 需要本机交互终端,密码不写入 plist、JSON 或命令参数。未配置密码时可安装检测服务,但无法恢复过期认证。后台任务不会继承一次性的 进程环境凭据,应使用 ChatEnv profile 或钥匙串。

配置与状态在 $CHATARCH_HOME/chatecnu/wifi-autologin/,任务文件在 ~/Library/LaunchAgents/com.chatarch.ecnu.wifi-autologin.plist。重装会备份旧配置与任务文件, 支持把原独立脚本任务迁到包内入口;安装器保留旧脚本文件。安装失败会恢复原文件。 服务运行在这台 Mac 上,关机、休眠或退出用户会话期间不检测;它不在路由器上运行。

Metadata

Release files for ChatECNU 0.2.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ChatECNU 0.2.10
File Size Uploaded Provenance Actions
chatecnu-0.2.10.tar.gz 5.3 MB With provenance Details for chatecnu-0.2.10.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ChatECNU 0.2.10
File Interpreter ABI Platform Actions
chatecnu-0.2.10-py3-none-any.whl Python 3 none any Details for chatecnu-0.2.10-py3-none-any.whl

Total release size: 10.6 MB

Release files / chatecnu-0.2.10.tar.gz

Download URL chatecnu-0.2.10.tar.gz
Size 5.3 MB
Tags Source
SHA-256 checksum
How to use checksums
25aa97937b0267c8dd7b0cab850ef86fd4e106af429f495eba23f2d5a9ee160c
BLAKE2b-256 checksum
How to use checksums
d7f359da14a3a76e62e2814a4678dfe1431dd175e9f2e140c9e4f097139f53dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Release files / chatecnu-0.2.10-py3-none-any.whl

Download URL chatecnu-0.2.10-py3-none-any.whl
Size 5.3 MB
Tags Python 3
SHA-256 checksum
How to use checksums
f23c844002a06fd1f688d3bda935fecc8ddc55ae3c2483dd9d445ed503206f84
BLAKE2b-256 checksum
How to use checksums
8ea8688d45b69c0bc07d85a9f587cb241ad2a508a870b0818af0ad50d5768db4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Security for ChatECNU 0.2.10

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for chatecnu-0.2.10.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page