From 9cc20520866f987510f9a63de9ab07904d754379 Mon Sep 17 00:00:00 2001 From: yanyongyu Date: Wed, 4 Aug 2021 14:32:13 +0800 Subject: [PATCH] :children_crossing: adapt to latest version --- src/plugins/github/__init__.py | 7 ++++--- src/plugins/github/apis/auth.py | 4 ++-- src/plugins/github/apis/hook.py | 4 ++-- src/plugins/github/libs/issue/__init__.py | 6 ++---- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/plugins/github/__init__.py b/src/plugins/github/__init__.py index 1a84cfa..ab30e88 100644 --- a/src/plugins/github/__init__.py +++ b/src/plugins/github/__init__.py @@ -4,7 +4,7 @@ @Author : yanyongyu @Date : 2020-09-20 23:59:20 @LastEditors : yanyongyu -@LastEditTime : 2021-03-15 23:10:18 +@LastEditTime : 2021-08-04 13:39:45 @Description : GitHub Main Plugin @GitHub : https://github.com/yanyongyu """ @@ -13,12 +13,13 @@ __author__ = "yanyongyu" from pathlib import Path import nonebot -from redis import Redis from .config import Config +# nonebot2 < 2.0.0-alpha.14 # quote with double quotes to use generic typing provided by pylance -redis: "Redis[bytes]" = nonebot.require("redis_provider").redis +# redis: "Redis[bytes]" = nonebot.require("redis_provider").redis +from src.plugins.redis_provider import redis_client as redis # store all github subplugins _sub_plugins = set() diff --git a/src/plugins/github/apis/auth.py b/src/plugins/github/apis/auth.py index fc6894c..a856097 100644 --- a/src/plugins/github/apis/auth.py +++ b/src/plugins/github/apis/auth.py @@ -4,7 +4,7 @@ @Author : yanyongyu @Date : 2021-03-15 20:18:19 @LastEditors : yanyongyu -@LastEditTime : 2021-06-14 01:25:35 +@LastEditTime : 2021-08-04 13:40:25 @Description : None @GitHub : https://github.com/yanyongyu """ @@ -19,7 +19,7 @@ except ImportError: pass else: - app: FastAPI = nonebot.get_driver().server_app + app: FastAPI = nonebot.get_app() @app.get("/api/github/auth") async def auth(code: str, state: str): diff --git a/src/plugins/github/apis/hook.py b/src/plugins/github/apis/hook.py index 14f4ee1..d57d6e7 100644 --- a/src/plugins/github/apis/hook.py +++ b/src/plugins/github/apis/hook.py @@ -4,7 +4,7 @@ @Author : yanyongyu @Date : 2021-03-16 01:11:47 @LastEditors : yanyongyu -@LastEditTime : 2021-03-31 23:14:18 +@LastEditTime : 2021-08-04 13:40:33 @Description : None @GitHub : https://github.com/yanyongyu """ @@ -16,7 +16,7 @@ from fastapi import FastAPI, Body # from ..libs.hook import get_repo_hook -app: FastAPI = nonebot.get_driver().server_app +app: FastAPI = nonebot.get_app() @app.post("/api/github/hook/{hook_id}") diff --git a/src/plugins/github/libs/issue/__init__.py b/src/plugins/github/libs/issue/__init__.py index 969a53a..2127517 100644 --- a/src/plugins/github/libs/issue/__init__.py +++ b/src/plugins/github/libs/issue/__init__.py @@ -4,7 +4,7 @@ @Author : yanyongyu @Date : 2021-03-09 16:45:25 @LastEditors : yanyongyu -@LastEditTime : 2021-06-15 22:20:20 +@LastEditTime : 2021-08-04 13:41:12 @Description : None @GitHub : https://github.com/yanyongyu """ @@ -13,8 +13,6 @@ __author__ = "yanyongyu" from datetime import timedelta from typing import Dict, Optional -from nonebot import require - from src.libs import html2img from src.libs.github import Github from ... import github_config as config @@ -22,7 +20,7 @@ from src.libs.github.models import Issue from src.libs.playwright import get_new_page from .render import issue_to_html, pr_diff_to_html -cache = require("redis_provider").cache +from src.plugins.redis_provider import cache async def get_issue(owner: str,