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.
Files changed (186) hide show
  1. butterbot_python-3.1.0.dev1/.github/workflows/ci.yml +79 -0
  2. butterbot_python-3.1.0.dev1/.github/workflows/release-on-version.yml +125 -0
  3. butterbot_python-3.1.0.dev1/.gitignore +51 -0
  4. butterbot_python-3.1.0.dev1/.markdownlint-cli2.mjs +11 -0
  5. butterbot_python-3.1.0.dev1/.pre-commit-config.yaml +18 -0
  6. butterbot_python-3.1.0.dev1/.python-version +1 -0
  7. butterbot_python-3.1.0.dev1/AGENTS.md +71 -0
  8. butterbot_python-3.1.0.dev1/LICENSE +674 -0
  9. butterbot_python-3.1.0.dev1/PKG-INFO +769 -0
  10. butterbot_python-3.1.0.dev1/README.md +76 -0
  11. butterbot_python-3.1.0.dev1/butterbot/__init__.py +15 -0
  12. butterbot_python-3.1.0.dev1/butterbot/app/__init__.py +41 -0
  13. butterbot_python-3.1.0.dev1/butterbot/app/bot_app.py +374 -0
  14. butterbot_python-3.1.0.dev1/butterbot/app/config.py +156 -0
  15. butterbot_python-3.1.0.dev1/butterbot/app/source_manager.py +367 -0
  16. butterbot_python-3.1.0.dev1/butterbot/core/__init__.py +46 -0
  17. butterbot_python-3.1.0.dev1/butterbot/core/api/__init__.py +9 -0
  18. butterbot_python-3.1.0.dev1/butterbot/core/api/base_api.py +32 -0
  19. butterbot_python-3.1.0.dev1/butterbot/core/context/README.md +1 -0
  20. butterbot_python-3.1.0.dev1/butterbot/core/context/__init__.py +9 -0
  21. butterbot_python-3.1.0.dev1/butterbot/core/context/api_registry.py +109 -0
  22. butterbot_python-3.1.0.dev1/butterbot/core/context/app_context.py +51 -0
  23. butterbot_python-3.1.0.dev1/butterbot/core/context/config_provider.py +14 -0
  24. butterbot_python-3.1.0.dev1/butterbot/core/data/__init__.py +15 -0
  25. butterbot_python-3.1.0.dev1/butterbot/core/data/base_data.py +29 -0
  26. butterbot_python-3.1.0.dev1/butterbot/core/data/base_model.py +197 -0
  27. butterbot_python-3.1.0.dev1/butterbot/core/event/README.md +1 -0
  28. butterbot_python-3.1.0.dev1/butterbot/core/event/__init__.py +10 -0
  29. butterbot_python-3.1.0.dev1/butterbot/core/event/event.py +27 -0
  30. butterbot_python-3.1.0.dev1/butterbot/core/event/event_bus.py +276 -0
  31. butterbot_python-3.1.0.dev1/butterbot/core/event/subscriber.py +130 -0
  32. butterbot_python-3.1.0.dev1/butterbot/core/exceptions.py +90 -0
  33. butterbot_python-3.1.0.dev1/butterbot/core/filter/__init__.py +11 -0
  34. butterbot_python-3.1.0.dev1/butterbot/core/filter/base_filter.py +74 -0
  35. butterbot_python-3.1.0.dev1/butterbot/core/source/README.md +1 -0
  36. butterbot_python-3.1.0.dev1/butterbot/core/source/__init__.py +9 -0
  37. butterbot_python-3.1.0.dev1/butterbot/core/source/base_source.py +134 -0
  38. butterbot_python-3.1.0.dev1/butterbot/core/types/__init__.py +9 -0
  39. butterbot_python-3.1.0.dev1/butterbot/core/types/base_type.py +74 -0
  40. butterbot_python-3.1.0.dev1/butterbot/sources/__init__.py +1 -0
  41. butterbot_python-3.1.0.dev1/butterbot/sources/bilibili/README.md +10 -0
  42. butterbot_python-3.1.0.dev1/butterbot/sources/bilibili/__init__.py +20 -0
  43. butterbot_python-3.1.0.dev1/butterbot/sources/bilibili/api/__init__.py +5 -0
  44. butterbot_python-3.1.0.dev1/butterbot/sources/bilibili/api/bili_api.py +123 -0
  45. butterbot_python-3.1.0.dev1/butterbot/sources/bilibili/data/__init__.py +52 -0
  46. butterbot_python-3.1.0.dev1/butterbot/sources/bilibili/data/danmaku_gift_data.py +135 -0
  47. butterbot_python-3.1.0.dev1/butterbot/sources/bilibili/data/danmaku_guard_data.py +54 -0
  48. butterbot_python-3.1.0.dev1/butterbot/sources/bilibili/data/danmaku_msg_data.py +71 -0
  49. butterbot_python-3.1.0.dev1/butterbot/sources/bilibili/data/dto/__init__.py +59 -0
  50. butterbot_python-3.1.0.dev1/butterbot/sources/bilibili/data/dto/danmaku_gift_dto.py +193 -0
  51. butterbot_python-3.1.0.dev1/butterbot/sources/bilibili/data/dto/danmaku_guard_buy_dto.py +54 -0
  52. butterbot_python-3.1.0.dev1/butterbot/sources/bilibili/data/dto/danmaku_msg_dto.py +123 -0
  53. butterbot_python-3.1.0.dev1/butterbot/sources/bilibili/data/dto/dynamic_dto.py +276 -0
  54. butterbot_python-3.1.0.dev1/butterbot/sources/bilibili/data/dto/live_room_dto.py +169 -0
  55. butterbot_python-3.1.0.dev1/butterbot/sources/bilibili/data/dto/video_part_dto.py +18 -0
  56. butterbot_python-3.1.0.dev1/butterbot/sources/bilibili/data/dynamic_data.py +362 -0
  57. butterbot_python-3.1.0.dev1/butterbot/sources/bilibili/data/live_room_data.py +162 -0
  58. butterbot_python-3.1.0.dev1/butterbot/sources/bilibili/data/video_part.py +46 -0
  59. butterbot_python-3.1.0.dev1/butterbot/sources/bilibili/source/__init__.py +15 -0
  60. butterbot_python-3.1.0.dev1/butterbot/sources/bilibili/source/base_polling_source.py +130 -0
  61. butterbot_python-3.1.0.dev1/butterbot/sources/bilibili/source/bili_danmaku_source.py +230 -0
  62. butterbot_python-3.1.0.dev1/butterbot/sources/bilibili/source/bili_dynamic_source.py +135 -0
  63. butterbot_python-3.1.0.dev1/butterbot/sources/bilibili/source/bili_live_source.py +137 -0
  64. butterbot_python-3.1.0.dev1/butterbot/sources/bilibili/types/__init__.py +11 -0
  65. butterbot_python-3.1.0.dev1/butterbot/sources/bilibili/types/bili_type.py +32 -0
  66. butterbot_python-3.1.0.dev1/butterbot/sources/napcat/README.md +10 -0
  67. butterbot_python-3.1.0.dev1/butterbot/sources/napcat/__init__.py +20 -0
  68. butterbot_python-3.1.0.dev1/butterbot/sources/napcat/api/__init__.py +3 -0
  69. butterbot_python-3.1.0.dev1/butterbot/sources/napcat/api/napcat_api.py +316 -0
  70. butterbot_python-3.1.0.dev1/butterbot/sources/napcat/data/__init__.py +179 -0
  71. butterbot_python-3.1.0.dev1/butterbot/sources/napcat/data/event_data.py +441 -0
  72. butterbot_python-3.1.0.dev1/butterbot/sources/napcat/data/segment_data.py +432 -0
  73. butterbot_python-3.1.0.dev1/butterbot/sources/napcat/events.py +91 -0
  74. butterbot_python-3.1.0.dev1/butterbot/sources/napcat/filters/__init__.py +19 -0
  75. butterbot_python-3.1.0.dev1/butterbot/sources/napcat/filters/filters.py +202 -0
  76. butterbot_python-3.1.0.dev1/butterbot/sources/napcat/source/__init__.py +5 -0
  77. butterbot_python-3.1.0.dev1/butterbot/sources/napcat/source/napcat_source.py +58 -0
  78. butterbot_python-3.1.0.dev1/butterbot/sources/napcat/types/__init__.py +5 -0
  79. butterbot_python-3.1.0.dev1/butterbot/sources/napcat/types/napcat_type.py +61 -0
  80. butterbot_python-3.1.0.dev1/butterbot/utils/README.md +15 -0
  81. butterbot_python-3.1.0.dev1/butterbot/utils/__init__.py +11 -0
  82. butterbot_python-3.1.0.dev1/butterbot/utils/data_pair.py +27 -0
  83. butterbot_python-3.1.0.dev1/butterbot/utils/logging_config.py +521 -0
  84. butterbot_python-3.1.0.dev1/butterbot/utils/terminal.py +308 -0
  85. butterbot_python-3.1.0.dev1/butterbot/utils/websocket.py +1270 -0
  86. butterbot_python-3.1.0.dev1/docs/.vuepress/collections.ts +71 -0
  87. butterbot_python-3.1.0.dev1/docs/.vuepress/config.ts +36 -0
  88. butterbot_python-3.1.0.dev1/docs/.vuepress/navbar.ts +14 -0
  89. butterbot_python-3.1.0.dev1/docs/.vuepress/plume.config.ts +23 -0
  90. butterbot_python-3.1.0.dev1/docs/.vuepress/styles/index.scss +25 -0
  91. butterbot_python-3.1.0.dev1/docs/404.md +13 -0
  92. butterbot_python-3.1.0.dev1/docs/README.md +80 -0
  93. butterbot_python-3.1.0.dev1/docs/api/README.md +42 -0
  94. butterbot_python-3.1.0.dev1/docs/api/app.md +138 -0
  95. butterbot_python-3.1.0.dev1/docs/api/builtin-sources.md +140 -0
  96. butterbot_python-3.1.0.dev1/docs/api/core.md +159 -0
  97. butterbot_python-3.1.0.dev1/docs/api/exceptions.md +54 -0
  98. butterbot_python-3.1.0.dev1/docs/architecture/README.md +57 -0
  99. butterbot_python-3.1.0.dev1/docs/architecture/control-flow.md +75 -0
  100. butterbot_python-3.1.0.dev1/docs/concepts/README.md +15 -0
  101. butterbot_python-3.1.0.dev1/docs/concepts/application-and-context.md +75 -0
  102. butterbot_python-3.1.0.dev1/docs/concepts/concurrency.md +81 -0
  103. butterbot_python-3.1.0.dev1/docs/concepts/data-models.md +88 -0
  104. butterbot_python-3.1.0.dev1/docs/concepts/errors.md +68 -0
  105. butterbot_python-3.1.0.dev1/docs/concepts/events-and-handlers.md +97 -0
  106. butterbot_python-3.1.0.dev1/docs/configuration/README.md +15 -0
  107. butterbot_python-3.1.0.dev1/docs/configuration/environment.md +56 -0
  108. butterbot_python-3.1.0.dev1/docs/configuration/runtime-config.md +62 -0
  109. butterbot_python-3.1.0.dev1/docs/configuration/yaml.md +100 -0
  110. butterbot_python-3.1.0.dev1/docs/contributing/README.md +144 -0
  111. butterbot_python-3.1.0.dev1/docs/examples/README.md +21 -0
  112. butterbot_python-3.1.0.dev1/docs/examples/bilibili.md +42 -0
  113. butterbot_python-3.1.0.dev1/docs/examples/minimal.md +41 -0
  114. butterbot_python-3.1.0.dev1/docs/examples/napcat.md +40 -0
  115. butterbot_python-3.1.0.dev1/docs/extensions/README.md +16 -0
  116. butterbot_python-3.1.0.dev1/docs/extensions/api.md +79 -0
  117. butterbot_python-3.1.0.dev1/docs/extensions/data-and-types.md +76 -0
  118. butterbot_python-3.1.0.dev1/docs/extensions/filters.md +57 -0
  119. butterbot_python-3.1.0.dev1/docs/extensions/source.md +95 -0
  120. butterbot_python-3.1.0.dev1/docs/extensions/testing.md +86 -0
  121. butterbot_python-3.1.0.dev1/docs/features/README.md +15 -0
  122. butterbot_python-3.1.0.dev1/docs/features/bilibili.md +100 -0
  123. butterbot_python-3.1.0.dev1/docs/features/dynamic-sources.md +77 -0
  124. butterbot_python-3.1.0.dev1/docs/features/napcat.md +99 -0
  125. butterbot_python-3.1.0.dev1/docs/features/subscriptions.md +96 -0
  126. butterbot_python-3.1.0.dev1/docs/guide/README.md +24 -0
  127. butterbot_python-3.1.0.dev1/docs/guide/installation.md +87 -0
  128. butterbot_python-3.1.0.dev1/docs/guide/introduction.md +58 -0
  129. butterbot_python-3.1.0.dev1/docs/guide/lifecycle.md +123 -0
  130. butterbot_python-3.1.0.dev1/docs/guide/project-structure.md +82 -0
  131. butterbot_python-3.1.0.dev1/docs/guide/quick-start.md +77 -0
  132. butterbot_python-3.1.0.dev1/docs/troubleshooting/README.md +15 -0
  133. butterbot_python-3.1.0.dev1/docs/troubleshooting/async-lifecycle.md +73 -0
  134. butterbot_python-3.1.0.dev1/docs/troubleshooting/installation.md +57 -0
  135. butterbot_python-3.1.0.dev1/docs/troubleshooting/runtime.md +63 -0
  136. butterbot_python-3.1.0.dev1/examples/config.example.yaml +29 -0
  137. butterbot_python-3.1.0.dev1/examples/live_danmaku_example.py +48 -0
  138. butterbot_python-3.1.0.dev1/examples/manager_example.py +105 -0
  139. butterbot_python-3.1.0.dev1/examples/minimal_source_example.py +71 -0
  140. butterbot_python-3.1.0.dev1/examples/napcat_example.py +209 -0
  141. butterbot_python-3.1.0.dev1/package-lock.json +10599 -0
  142. butterbot_python-3.1.0.dev1/package.json +34 -0
  143. butterbot_python-3.1.0.dev1/pyproject.toml +80 -0
  144. butterbot_python-3.1.0.dev1/scripts/check-doc-links.mjs +77 -0
  145. butterbot_python-3.1.0.dev1/tests/__init__.py +0 -0
  146. butterbot_python-3.1.0.dev1/tests/app/__init__.py +0 -0
  147. butterbot_python-3.1.0.dev1/tests/app/test_bot_app.py +431 -0
  148. butterbot_python-3.1.0.dev1/tests/app/test_config.py +171 -0
  149. butterbot_python-3.1.0.dev1/tests/app/test_source_manager.py +501 -0
  150. butterbot_python-3.1.0.dev1/tests/conftest.py +25 -0
  151. butterbot_python-3.1.0.dev1/tests/core/__init__.py +0 -0
  152. butterbot_python-3.1.0.dev1/tests/core/context/__init__.py +0 -0
  153. butterbot_python-3.1.0.dev1/tests/core/context/test_api_registry.py +224 -0
  154. butterbot_python-3.1.0.dev1/tests/core/context/test_app_context.py +75 -0
  155. butterbot_python-3.1.0.dev1/tests/core/data/__init__.py +0 -0
  156. butterbot_python-3.1.0.dev1/tests/core/data/test_base_data.py +44 -0
  157. butterbot_python-3.1.0.dev1/tests/core/data/test_base_model.py +153 -0
  158. butterbot_python-3.1.0.dev1/tests/core/event/__init__.py +0 -0
  159. butterbot_python-3.1.0.dev1/tests/core/event/test_event.py +64 -0
  160. butterbot_python-3.1.0.dev1/tests/core/event/test_event_bus.py +557 -0
  161. butterbot_python-3.1.0.dev1/tests/core/event/test_event_bus_close.py +231 -0
  162. butterbot_python-3.1.0.dev1/tests/core/event/test_subscriber.py +197 -0
  163. butterbot_python-3.1.0.dev1/tests/core/filter/__init__.py +0 -0
  164. butterbot_python-3.1.0.dev1/tests/core/filter/test_base_filter.py +131 -0
  165. butterbot_python-3.1.0.dev1/tests/core/source/__init__.py +0 -0
  166. butterbot_python-3.1.0.dev1/tests/core/source/test_base_source.py +129 -0
  167. butterbot_python-3.1.0.dev1/tests/core/test_exceptions.py +80 -0
  168. butterbot_python-3.1.0.dev1/tests/core/types/__init__.py +0 -0
  169. butterbot_python-3.1.0.dev1/tests/core/types/test_base_type.py +255 -0
  170. butterbot_python-3.1.0.dev1/tests/sources/__init__.py +0 -0
  171. butterbot_python-3.1.0.dev1/tests/sources/bilibili/__init__.py +0 -0
  172. butterbot_python-3.1.0.dev1/tests/sources/bilibili/test_polling_base.py +58 -0
  173. butterbot_python-3.1.0.dev1/tests/sources/bilibili/test_polling_rhythm.py +146 -0
  174. butterbot_python-3.1.0.dev1/tests/sources/napcat/__init__.py +0 -0
  175. butterbot_python-3.1.0.dev1/tests/sources/napcat/filters/__init__.py +0 -0
  176. butterbot_python-3.1.0.dev1/tests/sources/napcat/filters/test_napcat_filters.py +380 -0
  177. butterbot_python-3.1.0.dev1/tests/sources/napcat/test_napcat_api.py +100 -0
  178. butterbot_python-3.1.0.dev1/tests/sources/napcat/test_napcat_source.py +55 -0
  179. butterbot_python-3.1.0.dev1/tests/sources/napcat/types/__init__.py +0 -0
  180. butterbot_python-3.1.0.dev1/tests/test_examples.py +57 -0
  181. butterbot_python-3.1.0.dev1/tests/test_package.py +30 -0
  182. butterbot_python-3.1.0.dev1/tests/utils/__init__.py +0 -0
  183. butterbot_python-3.1.0.dev1/tests/utils/test_data_pair.py +63 -0
  184. butterbot_python-3.1.0.dev1/tests/utils/test_logging_config.py +122 -0
  185. butterbot_python-3.1.0.dev1/tests/utils/test_websocket.py +373 -0
  186. 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,11 @@
1
+ export default {
2
+ config: {
3
+ MD013: false,
4
+ MD024: { siblings_only: true },
5
+ MD025: false,
6
+ MD033: false,
7
+ MD041: false,
8
+ },
9
+ globs: ["README.md", "docs/**/*.md"],
10
+ ignores: ["docs/.vuepress/**", "docs/review/**"],
11
+ }
@@ -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.