summaryrefslogtreecommitdiff
path: root/ATRI/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'ATRI/plugins')
-rw-r--r--ATRI/plugins/console/__init__.py4
-rw-r--r--ATRI/plugins/console/driver/__init__.py4
-rw-r--r--ATRI/plugins/essential.py20
-rw-r--r--ATRI/plugins/help/data_source.py5
-rw-r--r--ATRI/plugins/repo.py4
-rw-r--r--ATRI/plugins/setu/__init__.py6
-rw-r--r--ATRI/plugins/setu/data_source.py6
-rw-r--r--ATRI/plugins/status/__init__.py4
8 files changed, 25 insertions, 28 deletions
diff --git a/ATRI/plugins/console/__init__.py b/ATRI/plugins/console/__init__.py
index 0764ab8..522998d 100644
--- a/ATRI/plugins/console/__init__.py
+++ b/ATRI/plugins/console/__init__.py
@@ -3,7 +3,7 @@ import json
from nonebot.params import ArgPlainText
from nonebot.adapters.onebot.v11 import PrivateMessageEvent, GroupMessageEvent
-from ATRI.config import BotSelfConfig
+from ATRI import conf
from ATRI.message import MessageBuilder
from ATRI.exceptions import WriteFileError
@@ -27,7 +27,7 @@ async def _(event: PrivateMessageEvent, is_pub_n: str = ArgPlainText("is_pub_n")
else:
host = str(await Console().get_host_ip(True))
- port = BotSelfConfig.port
+ port = conf.BotConfig.port
token = Console().get_random_str(20)
data = json.loads(data_path.read_bytes())
diff --git a/ATRI/plugins/console/driver/__init__.py b/ATRI/plugins/console/driver/__init__.py
index 970c91a..e4f8f71 100644
--- a/ATRI/plugins/console/driver/__init__.py
+++ b/ATRI/plugins/console/driver/__init__.py
@@ -3,8 +3,8 @@ from nonebot.drivers.fastapi import Driver
from fastapi.staticfiles import StaticFiles
from fastapi.middleware.cors import CORSMiddleware
+from ATRI import conf
from ATRI.log import log
-from ATRI.log import BotSelfConfig
from ATRI.plugins.console.data_source import FRONTEND_DIR
from .view import (
handle_auther,
@@ -64,6 +64,6 @@ def register_routes(driver: Driver):
def init_driver():
from ATRI import driver
- c_url = f"{BotSelfConfig.host}:{BotSelfConfig.port}"
+ c_url = f"{conf.BotConfig.host}:{conf.BotConfig.port}"
log.info(f"控制台将运行于: http://{c_url} 对应API节点为: /capi")
register_routes(driver()) # type: ignore
diff --git a/ATRI/plugins/essential.py b/ATRI/plugins/essential.py
index d40856d..c9b48a7 100644
--- a/ATRI/plugins/essential.py
+++ b/ATRI/plugins/essential.py
@@ -27,11 +27,9 @@ from nonebot.adapters.onebot.v11 import (
Message,
)
-
+from ATRI import conf
from ATRI.service import Service
from ATRI.log import log
-from ATRI.config import BotSelfConfig
-
from ATRI.utils import MessageChecker
from ATRI.utils.apscheduler import scheduler
@@ -142,7 +140,7 @@ async def _friend_add(bot: Bot, event: FriendRequestEvent):
f"申请码:{apply_code}\n"
"Tip: 获取好友申请"
)
- for superuser in BotSelfConfig.superusers:
+ for superuser in conf.BotConfig.superusers:
await bot.send_private_msg(user_id=superuser, message=repo)
@@ -188,7 +186,7 @@ async def _group_invite(bot: Bot, event: GroupRequestEvent):
f"申请码:{apply_code}\n"
"Tip: 获取邀请列表"
)
- for superuser in BotSelfConfig.superusers:
+ for superuser in conf.BotConfig.superusers:
await bot.send_private_msg(user_id=superuser, message=repo)
@@ -198,7 +196,7 @@ group_member_event = Essential().on_notice("群成员变动", "群成员变动�
@group_member_event.handle()
async def _group_member_join(bot: Bot, event: GroupIncreaseNoticeEvent):
await asyncio.sleep(randint(1, 6))
- msg = "好欸!事新人!\n" f"在下 {choice(list(BotSelfConfig.nickname))} 哒!w!"
+ msg = "好欸!事新人!\n" f"在下 {choice(list(conf.BotConfig.nickname))} 哒!w!"
await group_member_event.finish(msg)
@@ -216,7 +214,7 @@ async def _group_admin_event(bot: Bot, event: GroupAdminNoticeEvent):
if not event.is_tome():
return
- for superuser in BotSelfConfig.superusers:
+ for superuser in conf.BotConfig.superusers:
await bot.send_private_msg(
user_id=int(superuser), message=f"好欸!主人!我在群 {event.group_id} 成为了管理!!"
)
@@ -236,11 +234,11 @@ async def _group_ban_event(bot: Bot, event: GroupBanNoticeEvent):
f"咱在群 {event.group_id} 被 {event.operator_id} 塞上了口球...\n"
f"时长...是 {event.duration} 秒"
)
- for superuser in BotSelfConfig.superusers:
+ for superuser in conf.BotConfig.superusers:
await bot.send_private_msg(user_id=int(superuser), message=msg)
else:
msg = "好欸!主人\n" f"咱在群 {event.group_id} 的口球被 {event.operator_id} 解除了!"
- for superuser in BotSelfConfig.superusers:
+ for superuser in conf.BotConfig.superusers:
await bot.send_private_msg(user_id=int(superuser), message=msg)
@@ -277,7 +275,7 @@ async def _recall_group_event(bot: Bot, event: GroupRecallNoticeEvent):
else:
return
msg = f"主人,咱拿到了一条撤回信息!\n{user}@[群:{group}]\n撤回了\n{m}"
- for superuser in BotSelfConfig.superusers:
+ for superuser in conf.BotConfig.superusers:
await bot.send_private_msg(user_id=int(superuser), message=Message(msg))
@@ -308,7 +306,7 @@ async def _recall_private_event(bot: Bot, event: FriendRecallNoticeEvent):
return
msg = f"主人,咱拿到了一条撤回信息!\n{user}@[私聊]撤回了\n{m}"
- for superuser in BotSelfConfig.superusers:
+ for superuser in conf.BotConfig.superusers:
await bot.send_private_msg(user_id=int(superuser), message=Message(msg))
diff --git a/ATRI/plugins/help/data_source.py b/ATRI/plugins/help/data_source.py
index e504818..a99b92e 100644
--- a/ATRI/plugins/help/data_source.py
+++ b/ATRI/plugins/help/data_source.py
@@ -3,10 +3,9 @@ import json
from tabulate import tabulate
-from ATRI import __version__
+from ATRI import __version__, conf
from ATRI.rule import to_bot
from ATRI.service import Service, SERVICES_DIR, ServiceTools
-from ATRI.config import BotSelfConfig
SERVICE_INFO_FORMAT = """
@@ -42,7 +41,7 @@ class Helper(Service):
@staticmethod
def about() -> str:
temp_list = list()
- for i in BotSelfConfig.nickname:
+ for i in conf.BotConfig.nickname:
temp_list.append(i)
nickname = "、".join(map(str, temp_list))
return (
diff --git a/ATRI/plugins/repo.py b/ATRI/plugins/repo.py
index fe92a3f..561e20b 100644
--- a/ATRI/plugins/repo.py
+++ b/ATRI/plugins/repo.py
@@ -5,8 +5,8 @@ from nonebot.params import CommandArg, ArgPlainText
from nonebot.adapters.onebot.v11 import Bot, MessageEvent, Message
from nonebot.adapters.onebot.v11.helpers import Cooldown
+from ATRI import conf
from ATRI.service import Service
-from ATRI.config import BotSelfConfig
from ATRI.message import MessageBuilder
@@ -44,7 +44,7 @@ async def _deal_repo(
user_id = event.get_user_id()
repo_0 = _REPO_FORMAT.format(user=user_id, msg=repo_msg)
- for superuser in BotSelfConfig.superusers:
+ for superuser in conf.BotConfig.superusers:
try:
await bot.send_private_msg(user_id=superuser, message=repo_0)
except Exception:
diff --git a/ATRI/plugins/setu/__init__.py b/ATRI/plugins/setu/__init__.py
index 7962af8..1e8af97 100644
--- a/ATRI/plugins/setu/__init__.py
+++ b/ATRI/plugins/setu/__init__.py
@@ -8,7 +8,7 @@ from nonebot.params import CommandArg, ArgPlainText
from nonebot.adapters.onebot.v11 import Bot, MessageEvent, Message, MessageSegment
from nonebot.adapters.onebot.v11.helpers import extract_image_urls, Cooldown
-from ATRI.config import BotSelfConfig
+from ATRI import conf
from .data_source import Setu
@@ -122,7 +122,7 @@ async def _setu_catcher(bot: Bot, event: MessageEvent):
s_repo = f"多张涩图来咧!\n{ss}\n最涩的达到:{'{:.2%}'.format(hso[0])}"
await bot.send(event, u_repo)
- for superuser in BotSelfConfig.superusers:
+ for superuser in conf.BotConfig.superusers:
await bot.send_private_msg(user_id=superuser, message=s_repo)
@@ -143,7 +143,7 @@ async def _deal_check(bot: Bot, event: MessageEvent):
if hso >= 0.75:
resu += "hso!不行我要发给别人看"
repo = f"涩图来咧!\n{MessageSegment.image(args[0])}\n涩值:{'{:.2%}'.format(hso)}"
- for superuser in BotSelfConfig.superusers:
+ for superuser in conf.BotConfig.superusers:
await bot.send_private_msg(user_id=superuser, message=repo)
elif 0.75 > hso >= 0.5:
diff --git a/ATRI/plugins/setu/data_source.py b/ATRI/plugins/setu/data_source.py
index 71649fe..faf8668 100644
--- a/ATRI/plugins/setu/data_source.py
+++ b/ATRI/plugins/setu/data_source.py
@@ -1,10 +1,10 @@
import asyncio
from nonebot.adapters.onebot.v11 import Bot, MessageSegment
+from ATRI import conf
from ATRI.service import Service
from ATRI.rule import is_in_service
from ATRI.utils import request
-from ATRI.config import Setu as ST
from .nsfw_checker import detect_image, init_model
@@ -20,8 +20,8 @@ class Setu(Service):
@staticmethod
def _use_proxy(url: str) -> str:
- if ST.reverse_proxy:
- return url.replace("i.pixiv.cat", ST.reverse_proxy_domain)
+ if conf.Setu.reverse_proxy:
+ return url.replace("i.pixiv.cat", conf.Setu.reverse_proxy_domain)
else:
return url
diff --git a/ATRI/plugins/status/__init__.py b/ATRI/plugins/status/__init__.py
index 9c43973..ee90c86 100644
--- a/ATRI/plugins/status/__init__.py
+++ b/ATRI/plugins/status/__init__.py
@@ -1,7 +1,7 @@
from nonebot import get_bot
+from ATRI import conf
from ATRI.log import log
-from ATRI.config import BotSelfConfig
from ATRI.utils.apscheduler import scheduler
from .data_source import Status
@@ -35,7 +35,7 @@ async def _():
log.warning(msg)
bot = get_bot()
- for super in BotSelfConfig.superusers:
+ for super in conf.BotConfig.superusers:
await bot.send_private_msg(user_id=super, message=msg)
log.info("资源消耗正常")