Compare commits

..

7 Commits

Author SHA1 Message Date
1031e9f9a5
💡 在 _choose_cookie 方法中添加适当注释 2024-12-24 22:11:21 +08:00
57e68ac0b9
👷 fix by ruff 2024-12-24 22:11:21 +08:00
29a807df5a
🐛 fix type hint 2024-12-24 22:11:20 +08:00
59846642cc
B站 cookie选择策略优化 2024-12-24 22:11:20 +08:00
github-actions[bot]
e45bf03e49 📝 Update changelog 2024-12-24 07:42:44 +00:00
3421e3ac5e 🐛 change "proxies" to "proxy" in http.py 2024-12-24 15:42:14 +08:00
5a7396bada 👷 fix case and PYTHONPATH env warning in Dockerfile
Some checks failed
test-build / Build Frontend (push) Has been cancelled
test-build / Smoke-test Coverage (macos-latest, 3.10) (push) Has been cancelled
test-build / Smoke-test Coverage (macos-latest, 3.11) (push) Has been cancelled
test-build / Smoke-test Coverage (macos-latest, 3.12) (push) Has been cancelled
test-build / Smoke-test Coverage (ubuntu-latest, 3.10) (push) Has been cancelled
test-build / Smoke-test Coverage (ubuntu-latest, 3.11) (push) Has been cancelled
test-build / Smoke-test Coverage (ubuntu-latest, 3.12) (push) Has been cancelled
test-build / Smoke-test Coverage (windows-latest, 3.10) (push) Has been cancelled
test-build / Smoke-test Coverage (windows-latest, 3.11) (push) Has been cancelled
test-build / Smoke-test Coverage (windows-latest, 3.12) (push) Has been cancelled
test-build / All-test Coverage (macos-latest, 3.10) (push) Has been cancelled
test-build / All-test Coverage (macos-latest, 3.11) (push) Has been cancelled
test-build / All-test Coverage (macos-latest, 3.12) (push) Has been cancelled
test-build / All-test Coverage (ubuntu-latest, 3.10) (push) Has been cancelled
test-build / All-test Coverage (ubuntu-latest, 3.11) (push) Has been cancelled
test-build / All-test Coverage (ubuntu-latest, 3.12) (push) Has been cancelled
test-build / All-test Coverage (windows-latest, 3.10) (push) Has been cancelled
test-build / All-test Coverage (windows-latest, 3.11) (push) Has been cancelled
test-build / All-test Coverage (windows-latest, 3.12) (push) Has been cancelled
pydantic1-compat-test / pydantic1 test (ubuntu-latest, 3.11) (push) Has been cancelled
Ruff Lint / Ruff Lint (push) Has been cancelled
test-build / Docker main (push) Has been cancelled
test-build / Docker main sentry (push) Has been cancelled
2024-12-17 16:29:10 +08:00
6 changed files with 12 additions and 10 deletions

View File

@ -9,6 +9,7 @@
### Bug 修复 ### Bug 修复
- :bug: 修复新版 httpx 中 proxy 不起效的问题 [@suyiiyii](https://github.com/suyiiyii) ([#669](https://github.com/MountainDash/nonebot-bison/pull/669))
- :bug: 修复 cookie 模块 type hint [@suyiiyii](https://github.com/suyiiyii) ([#658](https://github.com/MountainDash/nonebot-bison/pull/658)) - :bug: 修复 cookie 模块 type hint [@suyiiyii](https://github.com/suyiiyii) ([#658](https://github.com/MountainDash/nonebot-bison/pull/658))
- :bug: B站转发动态补充 DeletedItem 类型解析 [@AzideCupric](https://github.com/AzideCupric) ([#659](https://github.com/MountainDash/nonebot-bison/pull/659)) - :bug: B站转发动态补充 DeletedItem 类型解析 [@AzideCupric](https://github.com/AzideCupric) ([#659](https://github.com/MountainDash/nonebot-bison/pull/659))
- :bug: 小刻食堂cdn使用https [@phidiaLam](https://github.com/phidiaLam) ([#650](https://github.com/MountainDash/nonebot-bison/pull/650)) - :bug: 小刻食堂cdn使用https [@phidiaLam](https://github.com/phidiaLam) ([#650](https://github.com/MountainDash/nonebot-bison/pull/650))

View File

@ -1,4 +1,4 @@
FROM node:22.11.0 as frontend FROM node:22.11.0 AS frontend
ADD . /app ADD . /app
WORKDIR /app/admin-frontend WORKDIR /app/admin-frontend
RUN npm install -g pnpm RUN npm install -g pnpm

View File

@ -1,7 +1,7 @@
# syntax=docker/dockerfile:1.10 # syntax=docker/dockerfile:1.10
FROM python:3.11-slim-bullseye as base FROM python:3.11-slim-bullseye AS base
FROM base as builder FROM base AS builder
ENV PYTHONFAULTHANDLER=1 \ ENV PYTHONFAULTHANDLER=1 \
PYTHONUNBUFFERED=1 \ PYTHONUNBUFFERED=1 \
@ -12,7 +12,6 @@ ENV PYTHONFAULTHANDLER=1 \
POETRY_NO_INTERACTION=1 \ POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_CREATE=false \ POETRY_VIRTUALENVS_CREATE=false \
PATH="$PATH:/runtime/bin" \ PATH="$PATH:/runtime/bin" \
PYTHONPATH="$PYTHONPATH:/runtime/lib/python3.10/site-packages" \
# Versions: # Versions:
POETRY_VERSION=1.7.1 POETRY_VERSION=1.7.1
RUN apt-get update && apt-get install -y build-essential unzip wget python-dev git RUN apt-get update && apt-get install -y build-essential unzip wget python-dev git
@ -25,7 +24,7 @@ COPY README.md pyproject.toml poetry.lock /src/
RUN poetry export --only=main,docker --without-hashes --no-interaction --no-ansi -f requirements.txt -o requirements.txt RUN poetry export --only=main,docker --without-hashes --no-interaction --no-ansi -f requirements.txt -o requirements.txt
RUN pip install --prefix=/runtime --force-reinstall -r requirements.txt RUN pip install --prefix=/runtime --force-reinstall -r requirements.txt
FROM base as runtime FROM base AS runtime
WORKDIR /app WORKDIR /app
RUN --mount=type=cache,target=/var/cache/apt \ RUN --mount=type=cache,target=/var/cache/apt \

View File

@ -1,7 +1,7 @@
# syntax=docker/dockerfile:1.10 # syntax=docker/dockerfile:1.10
FROM python:3.11-slim-bullseye as base FROM python:3.11-slim-bullseye AS base
FROM base as builder FROM base AS builder
ENV PYTHONFAULTHANDLER=1 \ ENV PYTHONFAULTHANDLER=1 \
PYTHONUNBUFFERED=1 \ PYTHONUNBUFFERED=1 \
@ -12,7 +12,6 @@ ENV PYTHONFAULTHANDLER=1 \
POETRY_NO_INTERACTION=1 \ POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_CREATE=false \ POETRY_VIRTUALENVS_CREATE=false \
PATH="$PATH:/runtime/bin" \ PATH="$PATH:/runtime/bin" \
PYTHONPATH="$PYTHONPATH:/runtime/lib/python3.10/site-packages" \
# Versions: # Versions:
POETRY_VERSION=1.7.1 POETRY_VERSION=1.7.1
RUN apt-get update && apt-get install -y build-essential unzip wget python3-dev git RUN apt-get update && apt-get install -y build-essential unzip wget python3-dev git
@ -25,7 +24,7 @@ COPY pyproject.toml poetry.lock /src/
RUN poetry export --only=main,docker --without-hashes --no-interaction --no-ansi -f requirements.txt -o requirements.txt RUN poetry export --only=main,docker --without-hashes --no-interaction --no-ansi -f requirements.txt -o requirements.txt
RUN pip install --prefix=/runtime --force-reinstall -r requirements.txt RUN pip install --prefix=/runtime --force-reinstall -r requirements.txt
FROM base as runtime FROM base AS runtime
WORKDIR /app WORKDIR /app
RUN --mount=type=cache,target=/var/cache/apt \ RUN --mount=type=cache,target=/var/cache/apt \

View File

@ -91,9 +91,12 @@ class BilibiliClientManager(CookieClientManager):
async def _choose_cookie(self, target: Target | None) -> CookieModel: async def _choose_cookie(self, target: Target | None) -> CookieModel:
"""选择 cookie 的具体算法""" """选择 cookie 的具体算法"""
if self._current_user_cookie is None: if self._current_user_cookie is None:
# 若当前没有选定用户 cookie 则尝试获取
self._current_user_cookie = await self._get_next_user_cookie() self._current_user_cookie = await self._get_next_user_cookie()
if self._current_user_cookie: if self._current_user_cookie:
# 如果当前有选定的用户 cookie 则直接返回
return self._current_user_cookie return self._current_user_cookie
# 否则返回匿名 cookie
return (await config.get_cookie(self._site_name, is_anonymous=True))[0] return (await config.get_cookie(self._site_name, is_anonymous=True))[0]
@override @override

View File

@ -3,7 +3,7 @@ import httpx
from nonebot_bison.plugin_config import plugin_config from nonebot_bison.plugin_config import plugin_config
http_args = { http_args = {
"proxies": plugin_config.bison_proxy or None, "proxy": plugin_config.bison_proxy or None,
} }
http_headers = {"user-agent": plugin_config.bison_ua} http_headers = {"user-agent": plugin_config.bison_ua}