summaryrefslogtreecommitdiff
path: root/ATRI/utils
diff options
context:
space:
mode:
authorKyomotoi <[email protected]>2022-02-03 14:36:24 +0800
committerKyomotoi <[email protected]>2022-02-03 14:36:24 +0800
commit3e32ca3964ff8f40e0b491e87f153040f2348fd0 (patch)
treed04d19ba5a25f6f1f6a9c4f8c398d49eb252df3c /ATRI/utils
parentf5a020d45f7294214bbcd488955b9c391d651a6d (diff)
downloadATRI-3e32ca3964ff8f40e0b491e87f153040f2348fd0.tar.gz
ATRI-3e32ca3964ff8f40e0b491e87f153040f2348fd0.tar.bz2
ATRI-3e32ca3964ff8f40e0b491e87f153040f2348fd0.zip
🔖 更新版本:
更新记录请参考文档: atri.kyomotoi.moe/changelog/overview/
Diffstat (limited to 'ATRI/utils')
-rw-r--r--ATRI/utils/__init__.py13
-rw-r--r--ATRI/utils/apscheduler.py8
-rw-r--r--ATRI/utils/request.py9
3 files changed, 19 insertions, 11 deletions
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)