ChatNet 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
chatnet-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ChatArch
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
chatnet-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,115 @@
1
+ Metadata-Version: 2.4
2
+ Name: ChatNet
3
+ Version: 0.1.0
4
+ Summary: ChatArch network and campus-network CLI
5
+ Author-email: ChatArch <1073853456@qq.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/ChatArch/ChatNet
8
+ Project-URL: Repository, https://github.com/ChatArch/ChatNet
9
+ Project-URL: Documentation, https://ChatArch.github.io/ChatNet
10
+ Keywords: chatnet,chatarch,cli
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Operating System :: OS Independent
13
+ Requires-Python: >=3.10
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: click>=8.0
17
+ Requires-Dist: chatstyle>=0.1.0
18
+ Requires-Dist: chatenv>=0.1.1
19
+ Requires-Dist: requests>=2.0
20
+ Requires-Dist: pycryptodome>=3.0
21
+ Provides-Extra: captcha
22
+ Requires-Dist: ddddocr; extra == "captcha"
23
+ Requires-Dist: numpy; extra == "captcha"
24
+ Requires-Dist: pillow; extra == "captcha"
25
+ Provides-Extra: dev
26
+ Requires-Dist: build; extra == "dev"
27
+ Requires-Dist: pytest; extra == "dev"
28
+ Requires-Dist: twine; extra == "dev"
29
+ Provides-Extra: docs
30
+ Requires-Dist: mkdocs>=1.4.0; extra == "docs"
31
+ Requires-Dist: mkdocs-material>=9.0.0; extra == "docs"
32
+ Requires-Dist: mike>=2.0.0; extra == "docs"
33
+ Dynamic: license-file
34
+
35
+ <div align="center">
36
+ <a href="https://pypi.python.org/pypi/ChatNet">
37
+ <img src="https://img.shields.io/pypi/v/ChatNet.svg" alt="PyPI version" />
38
+ </a>
39
+ <a href="https://github.com/ChatArch/ChatNet/actions/workflows/ci.yml">
40
+ <img src="https://github.com/ChatArch/ChatNet/actions/workflows/ci.yml/badge.svg" alt="Tests" />
41
+ </a>
42
+ <a href="https://ChatArch.github.io/ChatNet">
43
+ <img src="https://img.shields.io/badge/docs-mkdocs-blue.svg" alt="Documentation" />
44
+ </a>
45
+ </div>
46
+
47
+ <div align="center">
48
+
49
+ [English](README.en.md) | [简体中文](README.md)
50
+ </div>
51
+
52
+ # ChatNet
53
+
54
+ ChatNet 是 ChatArch 系列的网络与校园网 CLI,当前提供 ECNU 自助服务平台登录、查询和访客管理能力。
55
+
56
+ ## 快速开始
57
+
58
+ ```bash
59
+ pip install -e ".[dev]"
60
+ chatnet hello ChatArch
61
+ chatnet ecnu selftest
62
+ python -m pytest -q
63
+ python -m build
64
+ ```
65
+
66
+ ## ECNU CLI
67
+
68
+ ECNU 自助服务平台能力统一挂在 `chatnet ecnu` 下,覆盖登录、会话、日志查询和访客管理。
69
+
70
+ 默认配置使用 chatenv 规范,位于 `~/.chatarch/envs/ECNU/.env`:
71
+
72
+ ```bash
73
+ chatenv cat -t ecnu
74
+ ```
75
+
76
+ ```bash
77
+ chatnet ecnu login-init
78
+ chatnet ecnu login --username "$ECNU_USERNAME" --password "$ECNU_PASSWORD" --captcha ABCD
79
+ chatnet ecnu home
80
+ chatnet ecnu auth-log --limit 10
81
+ chatnet ecnu visitor list
82
+ chatnet ecnu visitor create --remark GuestB
83
+ chatnet ecnu visitor update --id 10256703 --remark GuestB --password 'Temp!235'
84
+ ```
85
+
86
+ 自动验证码登录依赖可选 OCR extra:
87
+
88
+ ```bash
89
+ pip install -e ".[captcha]"
90
+ chatnet ecnu login-auto --username "$ECNU_USERNAME" --password "$ECNU_PASSWORD"
91
+ ```
92
+
93
+ 缺少可恢复参数时,命令会按 ChatArch 规范进入交互补问;`-i` 强制交互,`-I` 禁止交互并快速失败。密码、Cookie、短信验证码等敏感值不要写入文档或提交记录。
94
+
95
+ 完整使用文档见 [`docs/ecnu.md`](docs/ecnu.md)。
96
+
97
+ ## CLI 规范
98
+
99
+ 这个模板默认依赖 `chatstyle>=0.1.0` 和 `chatenv>=0.1.1`,新的命令应优先使用:
100
+
101
+ - `CommandSchema` / `CommandField` 描述输入。
102
+ - `add_interactive_option()` 提供统一 `-i/-I`。
103
+ - `resolve_command_inputs()` 统一缺参补问、默认值、TTY 与校验。
104
+
105
+ ## 目录结构
106
+
107
+ - `src/`:包源码
108
+ - `tests/code-tests/`:代码测试和历史测试迁移
109
+ - `tests/cli-tests/`:真实 CLI 测试,doc-first
110
+ - `tests/mock-cli-tests/`:mock/fake CLI 测试,doc-first
111
+ - `docs/`:长期维护文档,由 mkdocs 构建
112
+
113
+ ## 开发说明
114
+
115
+ 扩展脚手架前,先阅读 `DEVELOP.md` 和 `AGENTS.md`。
@@ -0,0 +1,81 @@
1
+ <div align="center">
2
+ <a href="https://pypi.python.org/pypi/ChatNet">
3
+ <img src="https://img.shields.io/pypi/v/ChatNet.svg" alt="PyPI version" />
4
+ </a>
5
+ <a href="https://github.com/ChatArch/ChatNet/actions/workflows/ci.yml">
6
+ <img src="https://github.com/ChatArch/ChatNet/actions/workflows/ci.yml/badge.svg" alt="Tests" />
7
+ </a>
8
+ <a href="https://ChatArch.github.io/ChatNet">
9
+ <img src="https://img.shields.io/badge/docs-mkdocs-blue.svg" alt="Documentation" />
10
+ </a>
11
+ </div>
12
+
13
+ <div align="center">
14
+
15
+ [English](README.en.md) | [简体中文](README.md)
16
+ </div>
17
+
18
+ # ChatNet
19
+
20
+ ChatNet 是 ChatArch 系列的网络与校园网 CLI,当前提供 ECNU 自助服务平台登录、查询和访客管理能力。
21
+
22
+ ## 快速开始
23
+
24
+ ```bash
25
+ pip install -e ".[dev]"
26
+ chatnet hello ChatArch
27
+ chatnet ecnu selftest
28
+ python -m pytest -q
29
+ python -m build
30
+ ```
31
+
32
+ ## ECNU CLI
33
+
34
+ ECNU 自助服务平台能力统一挂在 `chatnet ecnu` 下,覆盖登录、会话、日志查询和访客管理。
35
+
36
+ 默认配置使用 chatenv 规范,位于 `~/.chatarch/envs/ECNU/.env`:
37
+
38
+ ```bash
39
+ chatenv cat -t ecnu
40
+ ```
41
+
42
+ ```bash
43
+ chatnet ecnu login-init
44
+ chatnet ecnu login --username "$ECNU_USERNAME" --password "$ECNU_PASSWORD" --captcha ABCD
45
+ chatnet ecnu home
46
+ chatnet ecnu auth-log --limit 10
47
+ chatnet ecnu visitor list
48
+ chatnet ecnu visitor create --remark GuestB
49
+ chatnet ecnu visitor update --id 10256703 --remark GuestB --password 'Temp!235'
50
+ ```
51
+
52
+ 自动验证码登录依赖可选 OCR extra:
53
+
54
+ ```bash
55
+ pip install -e ".[captcha]"
56
+ chatnet ecnu login-auto --username "$ECNU_USERNAME" --password "$ECNU_PASSWORD"
57
+ ```
58
+
59
+ 缺少可恢复参数时,命令会按 ChatArch 规范进入交互补问;`-i` 强制交互,`-I` 禁止交互并快速失败。密码、Cookie、短信验证码等敏感值不要写入文档或提交记录。
60
+
61
+ 完整使用文档见 [`docs/ecnu.md`](docs/ecnu.md)。
62
+
63
+ ## CLI 规范
64
+
65
+ 这个模板默认依赖 `chatstyle>=0.1.0` 和 `chatenv>=0.1.1`,新的命令应优先使用:
66
+
67
+ - `CommandSchema` / `CommandField` 描述输入。
68
+ - `add_interactive_option()` 提供统一 `-i/-I`。
69
+ - `resolve_command_inputs()` 统一缺参补问、默认值、TTY 与校验。
70
+
71
+ ## 目录结构
72
+
73
+ - `src/`:包源码
74
+ - `tests/code-tests/`:代码测试和历史测试迁移
75
+ - `tests/cli-tests/`:真实 CLI 测试,doc-first
76
+ - `tests/mock-cli-tests/`:mock/fake CLI 测试,doc-first
77
+ - `docs/`:长期维护文档,由 mkdocs 构建
78
+
79
+ ## 开发说明
80
+
81
+ 扩展脚手架前,先阅读 `DEVELOP.md` 和 `AGENTS.md`。
@@ -0,0 +1,49 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "ChatNet"
7
+ dynamic = ["version"]
8
+ description = "ChatArch network and campus-network CLI"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = "MIT"
12
+ dependencies = [
13
+ "click>=8.0",
14
+ "chatstyle>=0.1.0",
15
+ "chatenv>=0.1.1",
16
+ "requests>=2.0",
17
+ "pycryptodome>=3.0",
18
+ ]
19
+ authors = [{name = "ChatArch", email = "1073853456@qq.com"}]
20
+ keywords = ["chatnet", "chatarch", "cli"]
21
+ classifiers = [
22
+ "Programming Language :: Python :: 3",
23
+ "Operating System :: OS Independent",
24
+ ]
25
+
26
+ [project.scripts]
27
+ chatnet = "chatnet.cli:main"
28
+
29
+ [project.entry-points."chatenv.configs"]
30
+ chatnet = "chatnet.config"
31
+
32
+ [project.urls]
33
+ Homepage = "https://github.com/ChatArch/ChatNet"
34
+ Repository = "https://github.com/ChatArch/ChatNet"
35
+ Documentation = "https://ChatArch.github.io/ChatNet"
36
+
37
+ [project.optional-dependencies]
38
+ captcha = ["ddddocr", "numpy", "pillow"]
39
+ dev = ["build", "pytest", "twine"]
40
+ docs = ["mkdocs>=1.4.0", "mkdocs-material>=9.0.0", "mike>=2.0.0"]
41
+
42
+ [tool.setuptools.dynamic]
43
+ version = {attr = "chatnet.__version__"}
44
+
45
+ [tool.setuptools.packages.find]
46
+ where = ["src"]
47
+
48
+ [tool.setuptools]
49
+ include-package-data = true
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,115 @@
1
+ Metadata-Version: 2.4
2
+ Name: ChatNet
3
+ Version: 0.1.0
4
+ Summary: ChatArch network and campus-network CLI
5
+ Author-email: ChatArch <1073853456@qq.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/ChatArch/ChatNet
8
+ Project-URL: Repository, https://github.com/ChatArch/ChatNet
9
+ Project-URL: Documentation, https://ChatArch.github.io/ChatNet
10
+ Keywords: chatnet,chatarch,cli
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Operating System :: OS Independent
13
+ Requires-Python: >=3.10
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: click>=8.0
17
+ Requires-Dist: chatstyle>=0.1.0
18
+ Requires-Dist: chatenv>=0.1.1
19
+ Requires-Dist: requests>=2.0
20
+ Requires-Dist: pycryptodome>=3.0
21
+ Provides-Extra: captcha
22
+ Requires-Dist: ddddocr; extra == "captcha"
23
+ Requires-Dist: numpy; extra == "captcha"
24
+ Requires-Dist: pillow; extra == "captcha"
25
+ Provides-Extra: dev
26
+ Requires-Dist: build; extra == "dev"
27
+ Requires-Dist: pytest; extra == "dev"
28
+ Requires-Dist: twine; extra == "dev"
29
+ Provides-Extra: docs
30
+ Requires-Dist: mkdocs>=1.4.0; extra == "docs"
31
+ Requires-Dist: mkdocs-material>=9.0.0; extra == "docs"
32
+ Requires-Dist: mike>=2.0.0; extra == "docs"
33
+ Dynamic: license-file
34
+
35
+ <div align="center">
36
+ <a href="https://pypi.python.org/pypi/ChatNet">
37
+ <img src="https://img.shields.io/pypi/v/ChatNet.svg" alt="PyPI version" />
38
+ </a>
39
+ <a href="https://github.com/ChatArch/ChatNet/actions/workflows/ci.yml">
40
+ <img src="https://github.com/ChatArch/ChatNet/actions/workflows/ci.yml/badge.svg" alt="Tests" />
41
+ </a>
42
+ <a href="https://ChatArch.github.io/ChatNet">
43
+ <img src="https://img.shields.io/badge/docs-mkdocs-blue.svg" alt="Documentation" />
44
+ </a>
45
+ </div>
46
+
47
+ <div align="center">
48
+
49
+ [English](README.en.md) | [简体中文](README.md)
50
+ </div>
51
+
52
+ # ChatNet
53
+
54
+ ChatNet 是 ChatArch 系列的网络与校园网 CLI,当前提供 ECNU 自助服务平台登录、查询和访客管理能力。
55
+
56
+ ## 快速开始
57
+
58
+ ```bash
59
+ pip install -e ".[dev]"
60
+ chatnet hello ChatArch
61
+ chatnet ecnu selftest
62
+ python -m pytest -q
63
+ python -m build
64
+ ```
65
+
66
+ ## ECNU CLI
67
+
68
+ ECNU 自助服务平台能力统一挂在 `chatnet ecnu` 下,覆盖登录、会话、日志查询和访客管理。
69
+
70
+ 默认配置使用 chatenv 规范,位于 `~/.chatarch/envs/ECNU/.env`:
71
+
72
+ ```bash
73
+ chatenv cat -t ecnu
74
+ ```
75
+
76
+ ```bash
77
+ chatnet ecnu login-init
78
+ chatnet ecnu login --username "$ECNU_USERNAME" --password "$ECNU_PASSWORD" --captcha ABCD
79
+ chatnet ecnu home
80
+ chatnet ecnu auth-log --limit 10
81
+ chatnet ecnu visitor list
82
+ chatnet ecnu visitor create --remark GuestB
83
+ chatnet ecnu visitor update --id 10256703 --remark GuestB --password 'Temp!235'
84
+ ```
85
+
86
+ 自动验证码登录依赖可选 OCR extra:
87
+
88
+ ```bash
89
+ pip install -e ".[captcha]"
90
+ chatnet ecnu login-auto --username "$ECNU_USERNAME" --password "$ECNU_PASSWORD"
91
+ ```
92
+
93
+ 缺少可恢复参数时,命令会按 ChatArch 规范进入交互补问;`-i` 强制交互,`-I` 禁止交互并快速失败。密码、Cookie、短信验证码等敏感值不要写入文档或提交记录。
94
+
95
+ 完整使用文档见 [`docs/ecnu.md`](docs/ecnu.md)。
96
+
97
+ ## CLI 规范
98
+
99
+ 这个模板默认依赖 `chatstyle>=0.1.0` 和 `chatenv>=0.1.1`,新的命令应优先使用:
100
+
101
+ - `CommandSchema` / `CommandField` 描述输入。
102
+ - `add_interactive_option()` 提供统一 `-i/-I`。
103
+ - `resolve_command_inputs()` 统一缺参补问、默认值、TTY 与校验。
104
+
105
+ ## 目录结构
106
+
107
+ - `src/`:包源码
108
+ - `tests/code-tests/`:代码测试和历史测试迁移
109
+ - `tests/cli-tests/`:真实 CLI 测试,doc-first
110
+ - `tests/mock-cli-tests/`:mock/fake CLI 测试,doc-first
111
+ - `docs/`:长期维护文档,由 mkdocs 构建
112
+
113
+ ## 开发说明
114
+
115
+ 扩展脚手架前,先阅读 `DEVELOP.md` 和 `AGENTS.md`。
@@ -0,0 +1,18 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/ChatNet.egg-info/PKG-INFO
5
+ src/ChatNet.egg-info/SOURCES.txt
6
+ src/ChatNet.egg-info/dependency_links.txt
7
+ src/ChatNet.egg-info/entry_points.txt
8
+ src/ChatNet.egg-info/requires.txt
9
+ src/ChatNet.egg-info/top_level.txt
10
+ src/chatnet/__init__.py
11
+ src/chatnet/cli.py
12
+ src/chatnet/config.py
13
+ src/chatnet/ecnu/__init__.py
14
+ src/chatnet/ecnu/captcha.py
15
+ src/chatnet/ecnu/cli.py
16
+ src/chatnet/ecnu/portal.py
17
+ tests/test_cli.py
18
+ tests/test_version.py
@@ -0,0 +1,5 @@
1
+ [chatenv.configs]
2
+ chatnet = chatnet.config
3
+
4
+ [console_scripts]
5
+ chatnet = chatnet.cli:main
@@ -0,0 +1,20 @@
1
+ click>=8.0
2
+ chatstyle>=0.1.0
3
+ chatenv>=0.1.1
4
+ requests>=2.0
5
+ pycryptodome>=3.0
6
+
7
+ [captcha]
8
+ ddddocr
9
+ numpy
10
+ pillow
11
+
12
+ [dev]
13
+ build
14
+ pytest
15
+ twine
16
+
17
+ [docs]
18
+ mkdocs>=1.4.0
19
+ mkdocs-material>=9.0.0
20
+ mike>=2.0.0
@@ -0,0 +1 @@
1
+ chatnet
@@ -0,0 +1,5 @@
1
+ """ChatArch network and campus-network CLI."""
2
+
3
+ __all__ = ["__version__"]
4
+
5
+ __version__ = "0.1.0"
@@ -0,0 +1,58 @@
1
+ """CLI entrypoint for chatnet."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import click
6
+ from chatstyle import (
7
+ CommandField,
8
+ CommandSchema,
9
+ add_interactive_option,
10
+ render_success,
11
+ resolve_command_inputs,
12
+ )
13
+
14
+
15
+ HELLO_SCHEMA = CommandSchema(
16
+ name="hello",
17
+ fields=(CommandField("name", prompt="name", required=True),),
18
+ )
19
+
20
+
21
+ class ChatNetGroup(click.Group):
22
+ """Top-level group that loads heavier feature groups on demand."""
23
+
24
+ def list_commands(self, ctx: click.Context) -> list[str]:
25
+ commands = set(super().list_commands(ctx))
26
+ commands.add("ecnu")
27
+ return sorted(commands)
28
+
29
+ def get_command(self, ctx: click.Context, cmd_name: str) -> click.Command | None:
30
+ if cmd_name == "ecnu":
31
+ from chatnet.ecnu.cli import cli as ecnu_cli
32
+
33
+ return ecnu_cli
34
+ return super().get_command(ctx, cmd_name)
35
+
36
+
37
+ @click.group(cls=ChatNetGroup)
38
+ def main() -> None:
39
+ """chatnet command line interface."""
40
+
41
+
42
+ @main.command()
43
+ @click.argument("name", required=False)
44
+ @add_interactive_option
45
+ def hello(name: str | None, interactive: bool | None) -> None:
46
+ """Print a greeting with ChatStyle-backed input resolution."""
47
+
48
+ values = resolve_command_inputs(
49
+ schema=HELLO_SCHEMA,
50
+ provided={"name": name},
51
+ interactive=interactive,
52
+ usage="Usage: chatnet hello [NAME]",
53
+ )
54
+ render_success(f"Hello, {values['name']}!")
55
+
56
+
57
+ if __name__ == "__main__":
58
+ main()
@@ -0,0 +1,21 @@
1
+ """ChatEnv configuration schemas provided by ChatNet."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from chatenv.fields import BaseEnvConfig, EnvField
6
+
7
+
8
+ class ECNUConfig(BaseEnvConfig):
9
+ """ECNU self-service portal environment variables."""
10
+
11
+ _title = "ECNU"
12
+ _aliases = ["ecnu", "chatnet-ecnu"]
13
+ _storage_dir = "ECNU"
14
+
15
+ ECNU_USERNAME = EnvField("ECNU_USERNAME", desc="ECNU username.")
16
+ ECNU_PASSWORD = EnvField("ECNU_PASSWORD", desc="ECNU password.", is_sensitive=True)
17
+ ECNU_COOKIE = EnvField("ECNU_COOKIE", desc="Authenticated ECNU portal Cookie header.", is_sensitive=True)
18
+ ECNU_BASE_URL = EnvField("ECNU_BASE_URL", default="https://login.ecnu.edu.cn:8800", desc="ECNU portal base URL.")
19
+
20
+
21
+ __all__ = ["ECNUConfig"]
@@ -0,0 +1,5 @@
1
+ """ECNU self-service portal integration for ChatNet."""
2
+
3
+ from .portal import BASE_URL, PortalClient
4
+
5
+ __all__ = ["BASE_URL", "PortalClient"]