update 0.0.6.0

This commit is contained in:
HibiKier
2021-11-04 16:11:50 +08:00
parent 21c1950898
commit 19d650c35d
217 changed files with 8213 additions and 5697 deletions
+19 -2
View File
@@ -13,7 +13,7 @@ from models.group_member_info import GroupInfoUser
from services.log import logger
from utils.utils import get_message_text, get_message_imgs
from .data_source import get_chat_result, hello, no_result
from configs.config import NICKNAME
from configs.config import NICKNAME, Config
__zx_plugin_name__ = "AI"
__plugin_usage__ = f"""
@@ -28,6 +28,23 @@ __plugin_settings__ = {
"limit_superuser": False,
"cmd": ["Ai", "ai", "AI", "aI"],
}
__plugin_configs__ = {
"TL_KEY": {
"value": [],
"help": "图灵Key"
},
"ALAPI_AI_CHECK": {
"value": False,
"help": "是否检测青云客骂娘回复",
"default_value": False
}
}
Config.add_plugin_config(
"alapi",
"ALAPI_TOKEN",
None,
help_="在https://admin.alapi.cn/user/login登录后获取token"
)
ai = on_message(rule=to_me(), priority=8)
@@ -36,7 +53,7 @@ ai = on_message(rule=to_me(), priority=8)
async def _(bot: Bot, event: MessageEvent, state: T_State):
msg = get_message_text(event.json())
imgs = get_message_imgs(event.json())
if "CQ:xml" in msg:
if "CQ:xml" in str(event.get_message()):
return
# 打招呼
if (not msg and not imgs) or msg in [
+5 -5
View File
@@ -4,11 +4,10 @@ import re
import aiohttp
from aiohttp.client import ClientSession
from configs.config import TL_KEY, ALAPI_TOKEN, ALAPI_AI_CHECK, NICKNAME
from configs.path_config import IMAGE_PATH, DATA_PATH
from services.log import logger
from utils.message_builder import image, face
from configs.config import Config, NICKNAME
try:
import ujson as json
@@ -70,6 +69,7 @@ async def tu_ling(text: str, img_url: str, user_id: int, sess: ClientSession) ->
:return: 图灵回复
"""
global index
TL_KEY = Config.get_config("ai", "TL_KEY")
try:
if text:
req = {
@@ -149,7 +149,7 @@ async def xie_ai(text: str, sess: ClientSession) -> str:
break
return (
content
if not content and not ALAPI_AI_CHECK
if not content and not Config.get_config("ai", "ALAPI_AI_CHECK")
else await check_text(content, sess)
)
@@ -200,9 +200,9 @@ async def check_text(text: str, sess: ClientSession) -> str:
:param text: 回复
:param sess: AIOHTTP SESSION
"""
if not ALAPI_TOKEN:
if not Config.get_config("alapi", "ALAPI_TOKEN"):
return text
params = {"token": ALAPI_TOKEN, "text": text}
params = {"token": Config.get_config("alapi", "ALAPI_TOKEN"), "text": text}
try:
async with sess.get(check_url, timeout=2, params=params) as response:
data = await response.json()