From 3e32ca3964ff8f40e0b491e87f153040f2348fd0 Mon Sep 17 00:00:00 2001 From: Kyomotoi Date: Thu, 3 Feb 2022 14:36:24 +0800 Subject: =?UTF-8?q?=F0=9F=94=96=20=E6=9B=B4=E6=96=B0=E7=89=88=E6=9C=AC:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 更新记录请参考文档: atri.kyomotoi.moe/changelog/overview/ --- ATRI/utils/__init__.py | 13 ++++++++++--- ATRI/utils/apscheduler.py | 8 ++++---- ATRI/utils/request.py | 9 +++++---- 3 files changed, 19 insertions(+), 11 deletions(-) (limited to 'ATRI/utils') diff --git a/ATRI/utils/__init__.py b/ATRI/utils/__init__.py index 68a69b6..480d00e 100644 --- a/ATRI/utils/__init__.py +++ b/ATRI/utils/__init__.py @@ -55,9 +55,9 @@ class ListDealer: return self.lst -class CoolqCodeChecker: +class MessageChecker: """ - 检查所传回的cq码是否存在被注入可能 + 检查所传回的信息是否存在被注入可能 """ tenc_gchat_url: str = "gchat.qpic.cn" @@ -67,7 +67,7 @@ class CoolqCodeChecker: self.text = text @property - def check(self) -> bool: + def check_cq_code(self) -> bool: _type = re.findall(r"CQ:(.*?),", self.text) for i in _type: if i == "image": @@ -83,6 +83,13 @@ class CoolqCodeChecker: return True else: return True + + @property + def check_image_url(self) -> bool: + if self.tenc_gchat_url not in self.text: + return False + else: + return True class FileDealer: diff --git a/ATRI/utils/apscheduler.py b/ATRI/utils/apscheduler.py index 2680f19..daf37f4 100644 --- a/ATRI/utils/apscheduler.py +++ b/ATRI/utils/apscheduler.py @@ -1,9 +1,10 @@ -# Fork from: https://github.com/nonebot/plugin-apscheduler - +""" +Fork from: https://github.com/nonebot/plugin-apscheduler +""" import logging from apscheduler.schedulers.asyncio import AsyncIOScheduler -from nonebot import get_driver, export +from nonebot import get_driver from nonebot.log import logger, LoguruHandler @@ -13,7 +14,6 @@ apscheduler_config: dict = {"apscheduler.timezone": "Asia/Shanghai"} driver = get_driver() scheduler = AsyncIOScheduler() -export().scheduler = scheduler async def _start_scheduler(): diff --git a/ATRI/utils/request.py b/ATRI/utils/request.py index 2cfce85..da0cdd4 100644 --- a/ATRI/utils/request.py +++ b/ATRI/utils/request.py @@ -2,16 +2,17 @@ import httpx from ATRI.config import BotSelfConfig -proxy = BotSelfConfig.proxy -if not proxy: +if not BotSelfConfig.proxy: proxy = dict() +else: + proxy = {"all://": BotSelfConfig.proxy} async def get(url: str, **kwargs): - async with httpx.AsyncClient(proxies=proxy) as client: + async with httpx.AsyncClient(proxies=proxy) as client: # type: ignore return await client.get(url, **kwargs) async def post(url: str, **kwargs): - async with httpx.AsyncClient(proxies=proxy) as client: + async with httpx.AsyncClient(proxies=proxy) as client: # type: ignore return await client.post(url, **kwargs) -- cgit v1.2.3