Skip to content

Commit fdae1c7

Browse files
authored
Initial commit
0 parents  commit fdae1c7

File tree

14 files changed

+2082
-0
lines changed

14 files changed

+2082
-0
lines changed

.env.test

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
PORT=8888
2+
LOG_LEVEL=DEBUG
3+
FASTAPI_RELOAD=false

.github/workflows/pypi-publish.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Publish
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
workflow_dispatch:
8+
9+
jobs:
10+
pypi-publish:
11+
name: Upload release to PyPI
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
16+
17+
- name: Install uv and set the python version
18+
uses: astral-sh/setup-uv@v6
19+
with:
20+
python-version: "3.12"
21+
22+
- name: Build a binary wheel and a source tarball
23+
run: >-
24+
uv build
25+
26+
- name: Publish distribution to PyPI
27+
uses: pypa/gh-action-pypi-publish@release/v1
28+
with:
29+
password: ${{ secrets.PYPI_API_TOKEN }}

.github/workflows/pytest.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Pytest
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
paths-ignore:
8+
- 'README.md'
9+
pull_request:
10+
11+
jobs:
12+
pytest:
13+
runs-on: ubuntu-latest
14+
env:
15+
LOG_LEVEL: DEBUG
16+
strategy:
17+
matrix:
18+
python-version:
19+
- "3.10"
20+
- "3.11"
21+
- "3.12"
22+
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v4
26+
27+
- name: Install uv and set the python version
28+
uses: astral-sh/setup-uv@v6
29+
with:
30+
python-version: ${{ matrix.python-version }}
31+
32+
- name: Install Dependencies for test group
33+
run: |
34+
uv sync --group test
35+
36+
- name: Run all tests
37+
run: |
38+
uv run pytest

.github/workflows/rename.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Initialize Repository
2+
3+
on:
4+
workflow_dispatch: # 手动触发,可用于仓库首次初始化
5+
push:
6+
paths:
7+
- 'LICENSE' # 当 LICENSE 文件发生变更时触发
8+
- '!.github/**'
9+
10+
jobs:
11+
init:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0 # 获取完整历史以确保可以正确提交
18+
token: ${{ secrets.GITHUB_TOKEN }} # 使用具有写入权限的token
19+
20+
- name: Set repository variables
21+
run: |
22+
# 从环境变量 GITHUB_REPOSITORY 中提取仓库名称和所有者(格式为 owner/repo)
23+
REPO_FULL="${GITHUB_REPOSITORY}"
24+
REPO_OWNER="${REPO_FULL%/*}"
25+
REPO_NAME="${REPO_FULL#*/}"
26+
# 将横杠替换为下划线
27+
UNDERSCORE_REPO_NAME=$(echo "$REPO_NAME" | tr '-' '_')
28+
echo "REPO_OWNER=${REPO_OWNER}" >> $GITHUB_ENV
29+
echo "REPO_NAME=${REPO_NAME}" >> $GITHUB_ENV
30+
echo "UNDERSCORE_REPO_NAME=${UNDERSCORE_REPO_NAME}" >> $GITHUB_ENV
31+
echo "Repository owner: $REPO_OWNER"
32+
echo "Repository name: $REPO_NAME"
33+
echo "Repository underscore name: $UNDERSCORE_REPO_NAME"
34+
35+
- name: Update README.md
36+
run: |
37+
# 替换 README.md 中的内容
38+
rm -f README.md
39+
sed -i.bak "s/{owner}/${REPO_OWNER}/g" readme_template.md
40+
sed -i.bak "s/{plugin-name}/${REPO_NAME}/g" readme_template.md
41+
sed -i.bak "s/nonebot_plugin_template/${UNDERSCORE_REPO_NAME}/g" readme_template.md
42+
mv readme_template.md README.md
43+
rm -f README.md.bak
44+
rm -f readme_template.md.bak
45+
46+
- name: Update pyproject.toml
47+
run: |
48+
# 替换 pyproject.toml 中的内容
49+
sed -i.bak "s/nonebot-plugin-template/${REPO_NAME}/g" pyproject.toml
50+
sed -i.bak "s/owner/${REPO_OWNER}/g" pyproject.toml
51+
sed -i.bak "s/nonebot_plugin_template/${UNDERSCORE_REPO_NAME}/g" pyproject.toml
52+
rm -f pyproject.toml.bak
53+
54+
- name: Rename plugin metadata
55+
run : |
56+
# 修改 nonebot_plugin_template/__init__.py 中的插件元数据 中的 homepage
57+
sed -i.bak "s/owner/${REPO_OWNER}/g" src/nonebot_plugin_template/__init__.py
58+
sed -i.bak "s/nonebot-plugin-template/${REPO_NAME}/g" src/nonebot_plugin_template/__init__.py
59+
rm -f src/nonebot_plugin_template/__init__.py.bak
60+
61+
- name: Rename plugin folder
62+
run: |
63+
if [ -d "src/nonebot_plugin_template" ]; then
64+
mv src/nonebot_plugin_template "src/${UNDERSCORE_REPO_NAME}"
65+
echo "Successfully renamed plugin folder to ${UNDERSCORE_REPO_NAME}"
66+
else
67+
echo "Directory src/nonebot_plugin_template not found."
68+
exit 1
69+
fi
70+
71+
- name: Rename tests/plugin_test plugin name
72+
run: |
73+
# 修改 tests/plugin_test.py 中的插件名称
74+
sed -i.bak "s/nonebot_plugin_template/${UNDERSCORE_REPO_NAME}/g" tests/plugin_test.py
75+
rm -f tests/plugin_test.py.bak
76+
77+
- name: Commit and push changes
78+
run: |
79+
git config user.name "github-actions[bot]"
80+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
81+
git add .
82+
git commit -m "🎉 Initialize repository with correct naming"
83+
git push

.gitignore

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
share/python-wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# PyInstaller
30+
# Usually these files are written by a python script from a template
31+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32+
*.manifest
33+
*.spec
34+
35+
# Installer logs
36+
pip-log.txt
37+
pip-delete-this-directory.txt
38+
39+
# Unit test / coverage reports
40+
htmlcov/
41+
.tox/
42+
.nox/
43+
.coverage
44+
.coverage.*
45+
.cache
46+
nosetests.xml
47+
coverage.xml
48+
*.cover
49+
*.py,cover
50+
.hypothesis/
51+
.pytest_cache/
52+
cover/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
.pybuilder/
76+
target/
77+
78+
# Jupyter Notebook
79+
.ipynb_checkpoints
80+
81+
# IPython
82+
profile_default/
83+
ipython_config.py
84+
85+
# pyenv
86+
# For a library or package, you might want to ignore these files since the code is
87+
# intended to run in multiple environments; otherwise, check them in:
88+
# .python-version
89+
90+
# pipenv
91+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
93+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
94+
# install all needed dependencies.
95+
#Pipfile.lock
96+
97+
# poetry
98+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99+
# This is especially recommended for binary packages to ensure reproducibility, and is more
100+
# commonly ignored for libraries.
101+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102+
#poetry.lock
103+
# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration
104+
poetry.toml
105+
106+
# pdm
107+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
108+
#pdm.lock
109+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
110+
# in version control.
111+
# https://pdm.fming.dev/#use-with-ide
112+
.pdm-python
113+
114+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
115+
__pypackages__/
116+
117+
# Celery stuff
118+
celerybeat-schedule
119+
celerybeat.pid
120+
121+
# SageMath parsed files
122+
*.sage.py
123+
124+
# Environments
125+
.env
126+
.venv
127+
env/
128+
venv/
129+
ENV/
130+
env.bak/
131+
venv.bak/
132+
133+
# Spyder project settings
134+
.spyderproject
135+
.spyproject
136+
137+
# Rope project settings
138+
.ropeproject
139+
140+
# mkdocs documentation
141+
/site
142+
143+
# mypy
144+
.mypy_cache/
145+
.dmypy.json
146+
dmypy.json
147+
148+
# Pyre type checker
149+
.pyre/
150+
151+
# pytype static type analyzer
152+
.pytype/
153+
154+
# Cython debug symbols
155+
cython_debug/
156+
157+
# ruff
158+
.ruff_cache/
159+
160+
# LSP config files
161+
pyrightconfig.json
162+
163+
bot.py
164+
165+
# PyCharm
166+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
167+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
168+
# and can be added to the global gitignore or merged into this file. For a more nuclear
169+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
170+
#.idea/
171+
172+
# VisualStudioCode
173+
.vscode/*
174+
!.vscode/settings.json
175+
!.vscode/tasks.json
176+
!.vscode/launch.json
177+
!.vscode/extensions.json
178+
!.vscode/*.code-snippets
179+
180+
# cache/
181+
# data/
182+
# config/
183+
184+
.DS_Store

.pre-commit-config.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
default_install_hook_types: [pre-commit, prepare-commit-msg]
2+
ci:
3+
autofix_commit_msg: ":rotating_light: auto fix by pre-commit hooks"
4+
autofix_prs: true
5+
autoupdate_branch: master
6+
autoupdate_schedule: monthly
7+
autoupdate_commit_msg: ":arrow_up: auto update by pre-commit hooks"
8+
repos:
9+
- repo: https://github.com/astral-sh/ruff-pre-commit
10+
rev: v0.11.8
11+
hooks:
12+
- id: ruff
13+
args: [--fix]
14+
stages: [pre-commit]
15+
- id: ruff-format
16+
stages: [pre-commit]
17+
18+
- repo: https://github.com/nonebot/nonemoji
19+
rev: v0.1.4
20+
hooks:
21+
- id: nonemoji
22+
stages: [prepare-commit-msg]

0 commit comments

Comments
 (0)