butterbot-python 3.1.0.dev1__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.
- butterbot_python-3.1.0.dev1/.github/workflows/ci.yml +79 -0
- butterbot_python-3.1.0.dev1/.github/workflows/release-on-version.yml +125 -0
- butterbot_python-3.1.0.dev1/.gitignore +51 -0
- butterbot_python-3.1.0.dev1/.markdownlint-cli2.mjs +11 -0
- butterbot_python-3.1.0.dev1/.pre-commit-config.yaml +18 -0
- butterbot_python-3.1.0.dev1/.python-version +1 -0
- butterbot_python-3.1.0.dev1/AGENTS.md +71 -0
- butterbot_python-3.1.0.dev1/LICENSE +674 -0
- butterbot_python-3.1.0.dev1/PKG-INFO +769 -0
- butterbot_python-3.1.0.dev1/README.md +76 -0
- butterbot_python-3.1.0.dev1/butterbot/__init__.py +15 -0
- butterbot_python-3.1.0.dev1/butterbot/app/__init__.py +41 -0
- butterbot_python-3.1.0.dev1/butterbot/app/bot_app.py +374 -0
- butterbot_python-3.1.0.dev1/butterbot/app/config.py +156 -0
- butterbot_python-3.1.0.dev1/butterbot/app/source_manager.py +367 -0
- butterbot_python-3.1.0.dev1/butterbot/core/__init__.py +46 -0
- butterbot_python-3.1.0.dev1/butterbot/core/api/__init__.py +9 -0
- butterbot_python-3.1.0.dev1/butterbot/core/api/base_api.py +32 -0
- butterbot_python-3.1.0.dev1/butterbot/core/context/README.md +1 -0
- butterbot_python-3.1.0.dev1/butterbot/core/context/__init__.py +9 -0
- butterbot_python-3.1.0.dev1/butterbot/core/context/api_registry.py +109 -0
- butterbot_python-3.1.0.dev1/butterbot/core/context/app_context.py +51 -0
- butterbot_python-3.1.0.dev1/butterbot/core/context/config_provider.py +14 -0
- butterbot_python-3.1.0.dev1/butterbot/core/data/__init__.py +15 -0
- butterbot_python-3.1.0.dev1/butterbot/core/data/base_data.py +29 -0
- butterbot_python-3.1.0.dev1/butterbot/core/data/base_model.py +197 -0
- butterbot_python-3.1.0.dev1/butterbot/core/event/README.md +1 -0
- butterbot_python-3.1.0.dev1/butterbot/core/event/__init__.py +10 -0
- butterbot_python-3.1.0.dev1/butterbot/core/event/event.py +27 -0
- butterbot_python-3.1.0.dev1/butterbot/core/event/event_bus.py +276 -0
- butterbot_python-3.1.0.dev1/butterbot/core/event/subscriber.py +130 -0
- butterbot_python-3.1.0.dev1/butterbot/core/exceptions.py +90 -0
- butterbot_python-3.1.0.dev1/butterbot/core/filter/__init__.py +11 -0
- butterbot_python-3.1.0.dev1/butterbot/core/filter/base_filter.py +74 -0
- butterbot_python-3.1.0.dev1/butterbot/core/source/README.md +1 -0
- butterbot_python-3.1.0.dev1/butterbot/core/source/__init__.py +9 -0
- butterbot_python-3.1.0.dev1/butterbot/core/source/base_source.py +134 -0
- butterbot_python-3.1.0.dev1/butterbot/core/types/__init__.py +9 -0
- butterbot_python-3.1.0.dev1/butterbot/core/types/base_type.py +74 -0
- butterbot_python-3.1.0.dev1/butterbot/sources/__init__.py +1 -0
- butterbot_python-3.1.0.dev1/butterbot/sources/bilibili/README.md +10 -0
- butterbot_python-3.1.0.dev1/butterbot/sources/bilibili/__init__.py +20 -0
- butterbot_python-3.1.0.dev1/butterbot/sources/bilibili/api/__init__.py +5 -0
- butterbot_python-3.1.0.dev1/butterbot/sources/bilibili/api/bili_api.py +123 -0
- butterbot_python-3.1.0.dev1/butterbot/sources/bilibili/data/__init__.py +52 -0
- butterbot_python-3.1.0.dev1/butterbot/sources/bilibili/data/danmaku_gift_data.py +135 -0
- butterbot_python-3.1.0.dev1/butterbot/sources/bilibili/data/danmaku_guard_data.py +54 -0
- butterbot_python-3.1.0.dev1/butterbot/sources/bilibili/data/danmaku_msg_data.py +71 -0
- butterbot_python-3.1.0.dev1/butterbot/sources/bilibili/data/dto/__init__.py +59 -0
- butterbot_python-3.1.0.dev1/butterbot/sources/bilibili/data/dto/danmaku_gift_dto.py +193 -0
- butterbot_python-3.1.0.dev1/butterbot/sources/bilibili/data/dto/danmaku_guard_buy_dto.py +54 -0
- butterbot_python-3.1.0.dev1/butterbot/sources/bilibili/data/dto/danmaku_msg_dto.py +123 -0
- butterbot_python-3.1.0.dev1/butterbot/sources/bilibili/data/dto/dynamic_dto.py +276 -0
- butterbot_python-3.1.0.dev1/butterbot/sources/bilibili/data/dto/live_room_dto.py +169 -0
- butterbot_python-3.1.0.dev1/butterbot/sources/bilibili/data/dto/video_part_dto.py +18 -0
- butterbot_python-3.1.0.dev1/butterbot/sources/bilibili/data/dynamic_data.py +362 -0
- butterbot_python-3.1.0.dev1/butterbot/sources/bilibili/data/live_room_data.py +162 -0
- butterbot_python-3.1.0.dev1/butterbot/sources/bilibili/data/video_part.py +46 -0
- butterbot_python-3.1.0.dev1/butterbot/sources/bilibili/source/__init__.py +15 -0
- butterbot_python-3.1.0.dev1/butterbot/sources/bilibili/source/base_polling_source.py +130 -0
- butterbot_python-3.1.0.dev1/butterbot/sources/bilibili/source/bili_danmaku_source.py +230 -0
- butterbot_python-3.1.0.dev1/butterbot/sources/bilibili/source/bili_dynamic_source.py +135 -0
- butterbot_python-3.1.0.dev1/butterbot/sources/bilibili/source/bili_live_source.py +137 -0
- butterbot_python-3.1.0.dev1/butterbot/sources/bilibili/types/__init__.py +11 -0
- butterbot_python-3.1.0.dev1/butterbot/sources/bilibili/types/bili_type.py +32 -0
- butterbot_python-3.1.0.dev1/butterbot/sources/napcat/README.md +10 -0
- butterbot_python-3.1.0.dev1/butterbot/sources/napcat/__init__.py +20 -0
- butterbot_python-3.1.0.dev1/butterbot/sources/napcat/api/__init__.py +3 -0
- butterbot_python-3.1.0.dev1/butterbot/sources/napcat/api/napcat_api.py +316 -0
- butterbot_python-3.1.0.dev1/butterbot/sources/napcat/data/__init__.py +179 -0
- butterbot_python-3.1.0.dev1/butterbot/sources/napcat/data/event_data.py +441 -0
- butterbot_python-3.1.0.dev1/butterbot/sources/napcat/data/segment_data.py +432 -0
- butterbot_python-3.1.0.dev1/butterbot/sources/napcat/events.py +91 -0
- butterbot_python-3.1.0.dev1/butterbot/sources/napcat/filters/__init__.py +19 -0
- butterbot_python-3.1.0.dev1/butterbot/sources/napcat/filters/filters.py +202 -0
- butterbot_python-3.1.0.dev1/butterbot/sources/napcat/source/__init__.py +5 -0
- butterbot_python-3.1.0.dev1/butterbot/sources/napcat/source/napcat_source.py +58 -0
- butterbot_python-3.1.0.dev1/butterbot/sources/napcat/types/__init__.py +5 -0
- butterbot_python-3.1.0.dev1/butterbot/sources/napcat/types/napcat_type.py +61 -0
- butterbot_python-3.1.0.dev1/butterbot/utils/README.md +15 -0
- butterbot_python-3.1.0.dev1/butterbot/utils/__init__.py +11 -0
- butterbot_python-3.1.0.dev1/butterbot/utils/data_pair.py +27 -0
- butterbot_python-3.1.0.dev1/butterbot/utils/logging_config.py +521 -0
- butterbot_python-3.1.0.dev1/butterbot/utils/terminal.py +308 -0
- butterbot_python-3.1.0.dev1/butterbot/utils/websocket.py +1270 -0
- butterbot_python-3.1.0.dev1/docs/.vuepress/collections.ts +71 -0
- butterbot_python-3.1.0.dev1/docs/.vuepress/config.ts +36 -0
- butterbot_python-3.1.0.dev1/docs/.vuepress/navbar.ts +14 -0
- butterbot_python-3.1.0.dev1/docs/.vuepress/plume.config.ts +23 -0
- butterbot_python-3.1.0.dev1/docs/.vuepress/styles/index.scss +25 -0
- butterbot_python-3.1.0.dev1/docs/404.md +13 -0
- butterbot_python-3.1.0.dev1/docs/README.md +80 -0
- butterbot_python-3.1.0.dev1/docs/api/README.md +42 -0
- butterbot_python-3.1.0.dev1/docs/api/app.md +138 -0
- butterbot_python-3.1.0.dev1/docs/api/builtin-sources.md +140 -0
- butterbot_python-3.1.0.dev1/docs/api/core.md +159 -0
- butterbot_python-3.1.0.dev1/docs/api/exceptions.md +54 -0
- butterbot_python-3.1.0.dev1/docs/architecture/README.md +57 -0
- butterbot_python-3.1.0.dev1/docs/architecture/control-flow.md +75 -0
- butterbot_python-3.1.0.dev1/docs/concepts/README.md +15 -0
- butterbot_python-3.1.0.dev1/docs/concepts/application-and-context.md +75 -0
- butterbot_python-3.1.0.dev1/docs/concepts/concurrency.md +81 -0
- butterbot_python-3.1.0.dev1/docs/concepts/data-models.md +88 -0
- butterbot_python-3.1.0.dev1/docs/concepts/errors.md +68 -0
- butterbot_python-3.1.0.dev1/docs/concepts/events-and-handlers.md +97 -0
- butterbot_python-3.1.0.dev1/docs/configuration/README.md +15 -0
- butterbot_python-3.1.0.dev1/docs/configuration/environment.md +56 -0
- butterbot_python-3.1.0.dev1/docs/configuration/runtime-config.md +62 -0
- butterbot_python-3.1.0.dev1/docs/configuration/yaml.md +100 -0
- butterbot_python-3.1.0.dev1/docs/contributing/README.md +144 -0
- butterbot_python-3.1.0.dev1/docs/examples/README.md +21 -0
- butterbot_python-3.1.0.dev1/docs/examples/bilibili.md +42 -0
- butterbot_python-3.1.0.dev1/docs/examples/minimal.md +41 -0
- butterbot_python-3.1.0.dev1/docs/examples/napcat.md +40 -0
- butterbot_python-3.1.0.dev1/docs/extensions/README.md +16 -0
- butterbot_python-3.1.0.dev1/docs/extensions/api.md +79 -0
- butterbot_python-3.1.0.dev1/docs/extensions/data-and-types.md +76 -0
- butterbot_python-3.1.0.dev1/docs/extensions/filters.md +57 -0
- butterbot_python-3.1.0.dev1/docs/extensions/source.md +95 -0
- butterbot_python-3.1.0.dev1/docs/extensions/testing.md +86 -0
- butterbot_python-3.1.0.dev1/docs/features/README.md +15 -0
- butterbot_python-3.1.0.dev1/docs/features/bilibili.md +100 -0
- butterbot_python-3.1.0.dev1/docs/features/dynamic-sources.md +77 -0
- butterbot_python-3.1.0.dev1/docs/features/napcat.md +99 -0
- butterbot_python-3.1.0.dev1/docs/features/subscriptions.md +96 -0
- butterbot_python-3.1.0.dev1/docs/guide/README.md +24 -0
- butterbot_python-3.1.0.dev1/docs/guide/installation.md +87 -0
- butterbot_python-3.1.0.dev1/docs/guide/introduction.md +58 -0
- butterbot_python-3.1.0.dev1/docs/guide/lifecycle.md +123 -0
- butterbot_python-3.1.0.dev1/docs/guide/project-structure.md +82 -0
- butterbot_python-3.1.0.dev1/docs/guide/quick-start.md +77 -0
- butterbot_python-3.1.0.dev1/docs/troubleshooting/README.md +15 -0
- butterbot_python-3.1.0.dev1/docs/troubleshooting/async-lifecycle.md +73 -0
- butterbot_python-3.1.0.dev1/docs/troubleshooting/installation.md +57 -0
- butterbot_python-3.1.0.dev1/docs/troubleshooting/runtime.md +63 -0
- butterbot_python-3.1.0.dev1/examples/config.example.yaml +29 -0
- butterbot_python-3.1.0.dev1/examples/live_danmaku_example.py +48 -0
- butterbot_python-3.1.0.dev1/examples/manager_example.py +105 -0
- butterbot_python-3.1.0.dev1/examples/minimal_source_example.py +71 -0
- butterbot_python-3.1.0.dev1/examples/napcat_example.py +209 -0
- butterbot_python-3.1.0.dev1/package-lock.json +10599 -0
- butterbot_python-3.1.0.dev1/package.json +34 -0
- butterbot_python-3.1.0.dev1/pyproject.toml +80 -0
- butterbot_python-3.1.0.dev1/scripts/check-doc-links.mjs +77 -0
- butterbot_python-3.1.0.dev1/tests/__init__.py +0 -0
- butterbot_python-3.1.0.dev1/tests/app/__init__.py +0 -0
- butterbot_python-3.1.0.dev1/tests/app/test_bot_app.py +431 -0
- butterbot_python-3.1.0.dev1/tests/app/test_config.py +171 -0
- butterbot_python-3.1.0.dev1/tests/app/test_source_manager.py +501 -0
- butterbot_python-3.1.0.dev1/tests/conftest.py +25 -0
- butterbot_python-3.1.0.dev1/tests/core/__init__.py +0 -0
- butterbot_python-3.1.0.dev1/tests/core/context/__init__.py +0 -0
- butterbot_python-3.1.0.dev1/tests/core/context/test_api_registry.py +224 -0
- butterbot_python-3.1.0.dev1/tests/core/context/test_app_context.py +75 -0
- butterbot_python-3.1.0.dev1/tests/core/data/__init__.py +0 -0
- butterbot_python-3.1.0.dev1/tests/core/data/test_base_data.py +44 -0
- butterbot_python-3.1.0.dev1/tests/core/data/test_base_model.py +153 -0
- butterbot_python-3.1.0.dev1/tests/core/event/__init__.py +0 -0
- butterbot_python-3.1.0.dev1/tests/core/event/test_event.py +64 -0
- butterbot_python-3.1.0.dev1/tests/core/event/test_event_bus.py +557 -0
- butterbot_python-3.1.0.dev1/tests/core/event/test_event_bus_close.py +231 -0
- butterbot_python-3.1.0.dev1/tests/core/event/test_subscriber.py +197 -0
- butterbot_python-3.1.0.dev1/tests/core/filter/__init__.py +0 -0
- butterbot_python-3.1.0.dev1/tests/core/filter/test_base_filter.py +131 -0
- butterbot_python-3.1.0.dev1/tests/core/source/__init__.py +0 -0
- butterbot_python-3.1.0.dev1/tests/core/source/test_base_source.py +129 -0
- butterbot_python-3.1.0.dev1/tests/core/test_exceptions.py +80 -0
- butterbot_python-3.1.0.dev1/tests/core/types/__init__.py +0 -0
- butterbot_python-3.1.0.dev1/tests/core/types/test_base_type.py +255 -0
- butterbot_python-3.1.0.dev1/tests/sources/__init__.py +0 -0
- butterbot_python-3.1.0.dev1/tests/sources/bilibili/__init__.py +0 -0
- butterbot_python-3.1.0.dev1/tests/sources/bilibili/test_polling_base.py +58 -0
- butterbot_python-3.1.0.dev1/tests/sources/bilibili/test_polling_rhythm.py +146 -0
- butterbot_python-3.1.0.dev1/tests/sources/napcat/__init__.py +0 -0
- butterbot_python-3.1.0.dev1/tests/sources/napcat/filters/__init__.py +0 -0
- butterbot_python-3.1.0.dev1/tests/sources/napcat/filters/test_napcat_filters.py +380 -0
- butterbot_python-3.1.0.dev1/tests/sources/napcat/test_napcat_api.py +100 -0
- butterbot_python-3.1.0.dev1/tests/sources/napcat/test_napcat_source.py +55 -0
- butterbot_python-3.1.0.dev1/tests/sources/napcat/types/__init__.py +0 -0
- butterbot_python-3.1.0.dev1/tests/test_examples.py +57 -0
- butterbot_python-3.1.0.dev1/tests/test_package.py +30 -0
- butterbot_python-3.1.0.dev1/tests/utils/__init__.py +0 -0
- butterbot_python-3.1.0.dev1/tests/utils/test_data_pair.py +63 -0
- butterbot_python-3.1.0.dev1/tests/utils/test_logging_config.py +122 -0
- butterbot_python-3.1.0.dev1/tests/utils/test_websocket.py +373 -0
- butterbot_python-3.1.0.dev1/uv.lock +1455 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
pull_request:
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
docs:
|
|
9
|
+
name: Documentation
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v6
|
|
14
|
+
with:
|
|
15
|
+
fetch-depth: 0
|
|
16
|
+
|
|
17
|
+
- name: Set up Node.js
|
|
18
|
+
uses: actions/setup-node@v6
|
|
19
|
+
with:
|
|
20
|
+
node-version: "24"
|
|
21
|
+
cache: npm
|
|
22
|
+
|
|
23
|
+
- name: Install documentation dependencies
|
|
24
|
+
run: npm ci
|
|
25
|
+
|
|
26
|
+
- name: Build and validate documentation
|
|
27
|
+
run: npm run docs:check
|
|
28
|
+
|
|
29
|
+
test:
|
|
30
|
+
name: Python ${{ matrix.python-version }}
|
|
31
|
+
runs-on: ubuntu-latest
|
|
32
|
+
strategy:
|
|
33
|
+
fail-fast: false
|
|
34
|
+
matrix:
|
|
35
|
+
python-version: ["3.12", "3.13", "3.14"]
|
|
36
|
+
|
|
37
|
+
steps:
|
|
38
|
+
- uses: actions/checkout@v6
|
|
39
|
+
|
|
40
|
+
- name: Set up Python
|
|
41
|
+
uses: actions/setup-python@v6
|
|
42
|
+
with:
|
|
43
|
+
python-version: ${{ matrix.python-version }}
|
|
44
|
+
|
|
45
|
+
- name: Install uv
|
|
46
|
+
uses: astral-sh/setup-uv@v7
|
|
47
|
+
with:
|
|
48
|
+
enable-cache: true
|
|
49
|
+
|
|
50
|
+
- name: Install dependencies
|
|
51
|
+
run: uv sync --locked --dev --python "${{ matrix.python-version }}"
|
|
52
|
+
|
|
53
|
+
- name: Lint
|
|
54
|
+
if: matrix.python-version == '3.12'
|
|
55
|
+
run: uv run ruff check .
|
|
56
|
+
|
|
57
|
+
- name: Format check
|
|
58
|
+
if: matrix.python-version == '3.12'
|
|
59
|
+
run: uv run ruff format --check .
|
|
60
|
+
|
|
61
|
+
- name: Type check
|
|
62
|
+
if: matrix.python-version == '3.12'
|
|
63
|
+
run: uv run pyright
|
|
64
|
+
|
|
65
|
+
- name: Test with coverage gate
|
|
66
|
+
if: matrix.python-version == '3.12'
|
|
67
|
+
run: >
|
|
68
|
+
uv run pytest
|
|
69
|
+
--cov=butterbot
|
|
70
|
+
--cov-report=term-missing
|
|
71
|
+
--cov-fail-under=70
|
|
72
|
+
|
|
73
|
+
- name: Test
|
|
74
|
+
if: matrix.python-version != '3.12'
|
|
75
|
+
run: uv run pytest
|
|
76
|
+
|
|
77
|
+
- name: Build distributions
|
|
78
|
+
if: matrix.python-version == '3.12'
|
|
79
|
+
run: uv build
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
name: Release on tag
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*"
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: write
|
|
10
|
+
id-token: write
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
release:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
|
|
16
|
+
steps:
|
|
17
|
+
- name: Checkout
|
|
18
|
+
uses: actions/checkout@v6
|
|
19
|
+
with:
|
|
20
|
+
fetch-depth: 0
|
|
21
|
+
|
|
22
|
+
- name: Set up Python
|
|
23
|
+
uses: actions/setup-python@v6
|
|
24
|
+
with:
|
|
25
|
+
python-version: "3.12"
|
|
26
|
+
|
|
27
|
+
- name: Install uv
|
|
28
|
+
uses: astral-sh/setup-uv@v7
|
|
29
|
+
with:
|
|
30
|
+
enable-cache: true
|
|
31
|
+
|
|
32
|
+
- name: Install dependencies
|
|
33
|
+
run: uv sync --locked --dev --python "3.12"
|
|
34
|
+
|
|
35
|
+
- name: Validate tag and branch
|
|
36
|
+
id: meta
|
|
37
|
+
shell: bash
|
|
38
|
+
run: |
|
|
39
|
+
TAG="${GITHUB_REF_NAME}"
|
|
40
|
+
|
|
41
|
+
git fetch origin main dev_main --prune
|
|
42
|
+
|
|
43
|
+
PROJECT_VERSION="$(python -c \
|
|
44
|
+
'import tomllib; print(tomllib.load(open("pyproject.toml", "rb"))["project"]["version"])')"
|
|
45
|
+
PROJECT_NAME="$(python -c \
|
|
46
|
+
'import tomllib; print(tomllib.load(open("pyproject.toml", "rb"))["project"]["name"])')"
|
|
47
|
+
if [[ "$PROJECT_NAME" != "butterbot-python" ]]; then
|
|
48
|
+
echo "Project name $PROJECT_NAME does not match expected package name butterbot-python"
|
|
49
|
+
exit 1
|
|
50
|
+
fi
|
|
51
|
+
|
|
52
|
+
TAG_VERSION="${TAG#v}"
|
|
53
|
+
if [[ "$TAG_VERSION" != "$PROJECT_VERSION" ]]; then
|
|
54
|
+
echo "Tag version $TAG_VERSION does not match project version $PROJECT_VERSION"
|
|
55
|
+
exit 1
|
|
56
|
+
fi
|
|
57
|
+
|
|
58
|
+
if [[ "$PROJECT_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
|
59
|
+
CHANNEL="stable"
|
|
60
|
+
REQUIRED_BRANCH="main"
|
|
61
|
+
PRERELEASE="false"
|
|
62
|
+
elif [[ "$PROJECT_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.dev[0-9]+$ ]]; then
|
|
63
|
+
CHANNEL="dev"
|
|
64
|
+
REQUIRED_BRANCH="dev_main"
|
|
65
|
+
PRERELEASE="true"
|
|
66
|
+
else
|
|
67
|
+
echo "Invalid project version: $PROJECT_VERSION"
|
|
68
|
+
echo "Expected stable tag: v3.0.5"
|
|
69
|
+
echo "Expected dev tag: v3.0.5.dev1"
|
|
70
|
+
exit 1
|
|
71
|
+
fi
|
|
72
|
+
|
|
73
|
+
if ! git branch -r --contains "$GITHUB_SHA" | grep -q "origin/${REQUIRED_BRANCH}$"; then
|
|
74
|
+
echo "Tag $TAG is not on required branch: $REQUIRED_BRANCH"
|
|
75
|
+
exit 1
|
|
76
|
+
fi
|
|
77
|
+
|
|
78
|
+
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
|
|
79
|
+
echo "channel=$CHANNEL" >> "$GITHUB_OUTPUT"
|
|
80
|
+
echo "prerelease=$PRERELEASE" >> "$GITHUB_OUTPUT"
|
|
81
|
+
|
|
82
|
+
- name: Lint
|
|
83
|
+
run: uv run ruff check .
|
|
84
|
+
|
|
85
|
+
- name: Format check
|
|
86
|
+
run: uv run ruff format --check .
|
|
87
|
+
|
|
88
|
+
- name: Type check
|
|
89
|
+
run: uv run pyright
|
|
90
|
+
|
|
91
|
+
- name: Test with coverage gate
|
|
92
|
+
run: >
|
|
93
|
+
uv run pytest
|
|
94
|
+
--cov=butterbot
|
|
95
|
+
--cov-report=term-missing
|
|
96
|
+
--cov-fail-under=70
|
|
97
|
+
|
|
98
|
+
- name: Build distributions
|
|
99
|
+
run: uv build
|
|
100
|
+
|
|
101
|
+
- name: Publish to PyPI
|
|
102
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
103
|
+
with:
|
|
104
|
+
packages-dir: dist/
|
|
105
|
+
|
|
106
|
+
- name: Create GitHub Release
|
|
107
|
+
shell: bash
|
|
108
|
+
env:
|
|
109
|
+
GH_TOKEN: ${{ github.token }}
|
|
110
|
+
TAG_NAME: ${{ steps.meta.outputs.tag }}
|
|
111
|
+
PRERELEASE: ${{ steps.meta.outputs.prerelease }}
|
|
112
|
+
run: |
|
|
113
|
+
RELEASE_ARGS=(
|
|
114
|
+
--title "$TAG_NAME"
|
|
115
|
+
--generate-notes
|
|
116
|
+
--verify-tag
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
if [[ "$PRERELEASE" == "true" ]]; then
|
|
120
|
+
RELEASE_ARGS+=(--prerelease --latest=false)
|
|
121
|
+
else
|
|
122
|
+
RELEASE_ARGS+=(--latest)
|
|
123
|
+
fi
|
|
124
|
+
|
|
125
|
+
gh release create "$TAG_NAME" dist/* "${RELEASE_ARGS[@]}"
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# === Python ===
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
|
|
5
|
+
# === Virtual Env ===
|
|
6
|
+
venv/
|
|
7
|
+
.venv/
|
|
8
|
+
|
|
9
|
+
# === Environment ===
|
|
10
|
+
.env
|
|
11
|
+
.env.*
|
|
12
|
+
|
|
13
|
+
# === Logs ===
|
|
14
|
+
*.log
|
|
15
|
+
logs
|
|
16
|
+
|
|
17
|
+
# === IDE ===
|
|
18
|
+
.idea/
|
|
19
|
+
.vscode/
|
|
20
|
+
|
|
21
|
+
# === OS ===
|
|
22
|
+
.DS_Store
|
|
23
|
+
Thumbs.db
|
|
24
|
+
|
|
25
|
+
# === Local config ===
|
|
26
|
+
config.local.py
|
|
27
|
+
settings.local.yaml
|
|
28
|
+
|
|
29
|
+
# === AI ===
|
|
30
|
+
CLAUDE.md
|
|
31
|
+
.claude
|
|
32
|
+
|
|
33
|
+
# === Dev ===
|
|
34
|
+
dev
|
|
35
|
+
output.txt
|
|
36
|
+
get_txt.py
|
|
37
|
+
.pyright/
|
|
38
|
+
.mypy_cache/
|
|
39
|
+
|
|
40
|
+
# === VuePress ===
|
|
41
|
+
node_modules/
|
|
42
|
+
docs/.vuepress/.cache/
|
|
43
|
+
docs/.vuepress/.temp/
|
|
44
|
+
docs/.vuepress/dist/
|
|
45
|
+
|
|
46
|
+
# === 用户凭证配置(切勿提交)===
|
|
47
|
+
/config.yaml
|
|
48
|
+
config.json
|
|
49
|
+
|
|
50
|
+
# === Coverage ===
|
|
51
|
+
.coverage
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
repos:
|
|
2
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
3
|
+
rev: v0.15.20
|
|
4
|
+
hooks:
|
|
5
|
+
- id: ruff
|
|
6
|
+
args: ["--fix"]
|
|
7
|
+
- id: ruff-format
|
|
8
|
+
|
|
9
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
10
|
+
rev: v5.0.0
|
|
11
|
+
hooks:
|
|
12
|
+
- id: trailing-whitespace
|
|
13
|
+
- id: end-of-file-fixer
|
|
14
|
+
- id: check-yaml
|
|
15
|
+
- id: check-toml
|
|
16
|
+
- id: check-json
|
|
17
|
+
- id: check-merge-conflict
|
|
18
|
+
- id: detect-private-key
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.12
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Repository Guidelines
|
|
2
|
+
|
|
3
|
+
## Project Structure & Module Organization
|
|
4
|
+
|
|
5
|
+
Production code lives in `butterbot/`. `core/` contains framework contracts,
|
|
6
|
+
events, data models, and lifecycle primitives; `app/` provides `BotApp`,
|
|
7
|
+
configuration, and source management; `sources/bilibili/` and
|
|
8
|
+
`sources/napcat/` contain integrations; `utils/` contains logging and WebSocket
|
|
9
|
+
support. Tests mirror this layout under `tests/`. User-facing examples and the
|
|
10
|
+
configuration template are in `examples/`, while architecture and API guides
|
|
11
|
+
are in `docs/`.
|
|
12
|
+
|
|
13
|
+
Keep dependencies flowing toward `core`: integrations may depend on core
|
|
14
|
+
contracts, but core must not import application or source implementations.
|
|
15
|
+
|
|
16
|
+
## Build, Test, and Development Commands
|
|
17
|
+
|
|
18
|
+
- `uv sync --locked --dev` installs the locked runtime and development
|
|
19
|
+
environment.
|
|
20
|
+
- `uv run pytest` runs the complete test suite.
|
|
21
|
+
- `uv run pytest --cov=butterbot --cov-report=term-missing --cov-fail-under=70`
|
|
22
|
+
enforces the CI coverage floor.
|
|
23
|
+
- `uv run ruff check .` checks imports and lint rules.
|
|
24
|
+
- `uv run ruff format --check .` verifies formatting; omit `--check` to format.
|
|
25
|
+
- `uv run pyright` runs static type checking.
|
|
26
|
+
- `uv build` creates the wheel and source distribution.
|
|
27
|
+
- `uv run pre-commit run --all-files` reproduces repository hooks.
|
|
28
|
+
|
|
29
|
+
Copy `examples/config.example.yaml` to `config.yaml` before running examples.
|
|
30
|
+
Never commit the resulting file or real credentials.
|
|
31
|
+
|
|
32
|
+
## Coding Style & Naming Conventions
|
|
33
|
+
|
|
34
|
+
Use Python 3.12+ syntax, four-space indentation, double quotes, and an 88-column
|
|
35
|
+
target. Ruff owns formatting and import ordering. Use `snake_case` for
|
|
36
|
+
functions/modules, `PascalCase` for classes, and descriptive type parameters.
|
|
37
|
+
Public APIs require useful type annotations. Preserve lifecycle ownership:
|
|
38
|
+
sources close their tasks, the event bus owns callback tasks, and APIs release
|
|
39
|
+
connections through `aclose()`.
|
|
40
|
+
|
|
41
|
+
Code comments should be written in Chinese when comments are needed. Prefer
|
|
42
|
+
comments that explain intent, constraints, or non-obvious behavior rather than
|
|
43
|
+
restating the code.
|
|
44
|
+
|
|
45
|
+
Function names, class names, and variable names should follow normal Python
|
|
46
|
+
naming conventions:
|
|
47
|
+
|
|
48
|
+
- `snake_case` for functions, methods, modules, and variables
|
|
49
|
+
- `PascalCase` for classes
|
|
50
|
+
- `UPPER_CASE` for constants when appropriate
|
|
51
|
+
|
|
52
|
+
## Testing Guidelines
|
|
53
|
+
|
|
54
|
+
Pytest and `pytest-asyncio` are used. Name files `test_*.py`, classes `Test*`,
|
|
55
|
+
and functions `test_*`. Add a regression test before fixing confirmed defects.
|
|
56
|
+
Tests must avoid external networks, ordering dependencies, unnecessary sleeps,
|
|
57
|
+
global-state leakage, and unfinished asyncio tasks. Cover cancellation,
|
|
58
|
+
timeouts, exception propagation, and idempotent shutdown when changing async
|
|
59
|
+
code.
|
|
60
|
+
|
|
61
|
+
## Commit & Pull Request Guidelines
|
|
62
|
+
|
|
63
|
+
Follow Conventional Commits for commit messages: keep the type and optional
|
|
64
|
+
scope in English, and write the subject in concise Chinese. Examples:
|
|
65
|
+
`feat: 新增配置加载` or `fix(core): 修复重复初始化`.
|
|
66
|
+
|
|
67
|
+
Keep each commit focused and include its tests.
|
|
68
|
+
|
|
69
|
+
Pull requests should explain the problem, behavioral and API impact,
|
|
70
|
+
verification commands, and related issue. Include logs for lifecycle or CLI
|
|
71
|
+
changes; screenshots are only needed for visual changes.
|