mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-14 21:52:56 +08:00
🎨 签到优化与配置修改
This commit is contained in:
parent
28b7415581
commit
f69253616e
20
.env.dev
20
.env.dev
@ -1,5 +1,3 @@
|
||||
|
||||
|
||||
SUPERUSERS=[""]
|
||||
|
||||
COMMAND_START=[""]
|
||||
@ -13,6 +11,12 @@ SESSION_EXPIRE_TIMEOUT=30
|
||||
# 全局图片统一使用bytes发送,当真寻与协议端不在同一服务器上时为True
|
||||
IMAGE_TO_BYTES = False
|
||||
|
||||
# 作为原config.py文件中的NICKNAME
|
||||
CONFIG_NICKNAME="小真寻"
|
||||
|
||||
# 作为原config.py文件中的SYSTEM_PROXY
|
||||
# SYSTEM_PROXY = "http://127.0.0.1:7890"
|
||||
|
||||
PLATFORM_SUPERUSERS = '
|
||||
{
|
||||
"qq": [""],
|
||||
@ -22,6 +26,12 @@ PLATFORM_SUPERUSERS = '
|
||||
|
||||
DRIVER=~fastapi+~httpx+~websockets
|
||||
|
||||
|
||||
# LOG_LEVEL=DEBUG
|
||||
# 服务器和端口
|
||||
HOST = 127.0.0.1
|
||||
PORT = 8080
|
||||
|
||||
# kook adapter toekn
|
||||
# kaiheila_bots =[{"token": ""}]
|
||||
|
||||
@ -53,9 +63,3 @@ DRIVER=~fastapi+~httpx+~websockets
|
||||
# application_commands的{"*": ["*"]}代表将全部应用命令注册为全局应用命令
|
||||
# {"admin": ["123", "456"]}则代表将admin命令注册为id是123、456服务器的局部命令,其余命令不注册
|
||||
|
||||
# LOG_LEVEL=DEBUG
|
||||
# 服务器和端口
|
||||
HOST = 127.0.0.1
|
||||
PORT = 8080
|
||||
|
||||
|
||||
@ -78,6 +78,10 @@ body {
|
||||
margin-top: 43px;
|
||||
margin-left: 30px;
|
||||
font-size: 47px;
|
||||
height: 57px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
display: flex
|
||||
}
|
||||
|
||||
.uid {
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
<img class="avatar-img" src="{{data.ava}}" alt="">
|
||||
</div>
|
||||
<div style="position: relative;">
|
||||
<p class="nickname">{{data.name}}</p>
|
||||
<p class="nickname" style="font-size: {{ data.font_size }}px;">{{data.name}}</p>
|
||||
<p class="uid">UID:{{data.uid}}</p>
|
||||
</div>
|
||||
</div>
|
||||
@ -30,7 +30,7 @@
|
||||
<img class="rl-img" class="avatar-img" src="res/img/rl.png" alt="">
|
||||
<img class="zx-img" class="avatar-img" src="res/img/1.png" alt="">
|
||||
<p class="text-day">累计签到{{data.sign_count}}天</p>
|
||||
<p class="text-zx">真寻说: {{data.message}}</p>
|
||||
<p class="text-zx">{{data.message}}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sign-data">
|
||||
@ -58,7 +58,7 @@
|
||||
</div>
|
||||
<div class="bot-text">
|
||||
<p style="position: absolute; top: 9px">好感度等级: {{data.level}}</p>
|
||||
<p style="position: absolute; top: 58px">小真寻对你的态度: {{data.attitude}}</p>
|
||||
<p style="position: absolute; top: 58px">{{data.attitude}}</p>
|
||||
<p style="position: absolute; top: 111px"">距离升级还差{{data.interpolation}}好感度</p>
|
||||
</div>
|
||||
<div class="progress-border">
|
||||
|
||||
@ -5,6 +5,7 @@ from nonebot.drivers import Driver
|
||||
from tortoise import Tortoise
|
||||
from tortoise.exceptions import OperationalError
|
||||
|
||||
from zhenxun.configs.config import BotConfig
|
||||
from zhenxun.models.goods_info import GoodsInfo
|
||||
from zhenxun.models.group_member_info import GroupInfoUser
|
||||
from zhenxun.models.sign_user import SignUser
|
||||
@ -46,6 +47,20 @@ from public.bag_users t1
|
||||
"""
|
||||
|
||||
|
||||
@driver.on_startup
|
||||
async def _():
|
||||
try:
|
||||
if driver.config.config_nickname:
|
||||
BotConfig.nickname = driver.config.config_nickname
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
if driver.config.system_proxy:
|
||||
BotConfig.system_proxy = driver.config.config_nickname
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
@driver.on_startup
|
||||
async def _():
|
||||
"""签到与用户的数据迁移"""
|
||||
|
||||
@ -7,7 +7,7 @@ from nonebot_plugin_alconna import Alconna, Arparma, on_alconna
|
||||
from nonebot_plugin_apscheduler import scheduler
|
||||
from nonebot_plugin_session import EventSession
|
||||
|
||||
from zhenxun.configs.config import NICKNAME
|
||||
from zhenxun.configs.config import BotConfig
|
||||
from zhenxun.configs.utils import PluginExtraData
|
||||
from zhenxun.services.log import logger
|
||||
from zhenxun.utils.enum import PluginType
|
||||
@ -62,7 +62,7 @@ async def _(bot: Bot, event: GroupIncreaseNoticeEvent):
|
||||
if str(event.user_id) == bot.self_id:
|
||||
await MemberUpdateManage.update(bot, str(event.group_id))
|
||||
logger.info(
|
||||
f"{NICKNAME}加入群聊更新群组信息",
|
||||
f"{BotConfig.nickname}加入群聊更新群组信息",
|
||||
"更新群组成员列表",
|
||||
session=event.user_id,
|
||||
group_id=event.group_id,
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import tarfile
|
||||
import zipfile
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
from nonebot.adapters import Bot
|
||||
@ -21,24 +21,34 @@ from .config import (
|
||||
MAIN_URL,
|
||||
PYPROJECT_FILE,
|
||||
PYPROJECT_LOCK_FILE,
|
||||
REQ_TXT_FILE,
|
||||
RELEASE_URL,
|
||||
REPLACE_FOLDERS,
|
||||
REQ_TXT_FILE,
|
||||
TMP_PATH,
|
||||
VERSION_FILE,
|
||||
)
|
||||
|
||||
|
||||
def install_requirement():
|
||||
requirement_path = (Path() / "requirements.txt").absolute()
|
||||
|
||||
|
||||
if not requirement_path.exists():
|
||||
logger.debug(f"没有找到zhenxun的requirement.txt,目标路径为{requirement_path}", "插件管理")
|
||||
logger.debug(
|
||||
f"没有找到zhenxun的requirement.txt,目标路径为{requirement_path}", "插件管理"
|
||||
)
|
||||
return
|
||||
try:
|
||||
result = subprocess.run(["pip", "install", "-r", str(requirement_path)], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
||||
result = subprocess.run(
|
||||
["pip", "install", "-r", str(requirement_path)],
|
||||
check=True,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
text=True,
|
||||
)
|
||||
logger.debug(f"成功安装真寻依赖,日志:\n{result.stdout}", "插件管理")
|
||||
except subprocess.CalledProcessError as e:
|
||||
logger.error(f"安装真寻依赖失败,错误:\n{e.stderr}")
|
||||
logger.error(f"安装真寻依赖失败,错误:\n{e.stderr}", "插件管理", e=e)
|
||||
|
||||
|
||||
@run_sync
|
||||
def _file_handle(latest_version: str | None):
|
||||
@ -120,6 +130,7 @@ def _file_handle(latest_version: str | None):
|
||||
f.write(f"__version__: {latest_version}")
|
||||
install_requirement()
|
||||
|
||||
|
||||
class UpdateManage:
|
||||
|
||||
@classmethod
|
||||
|
||||
@ -22,4 +22,11 @@ BACKUP_PATH = Path() / "backup"
|
||||
DOWNLOAD_GZ_FILE = TMP_PATH / "download_latest_file.tar.gz"
|
||||
DOWNLOAD_ZIP_FILE = TMP_PATH / "download_latest_file.zip"
|
||||
|
||||
REPLACE_FOLDERS = ["builtin_plugins", "plugins", "services", "utils", "models"]
|
||||
REPLACE_FOLDERS = [
|
||||
"builtin_plugins",
|
||||
"plugins",
|
||||
"services",
|
||||
"utils",
|
||||
"models",
|
||||
"configs",
|
||||
]
|
||||
|
||||
@ -10,7 +10,7 @@ from nonebot_plugin_alconna import Alconna, Option, on_alconna, store_true
|
||||
from nonebot_plugin_session import EventSession
|
||||
from nonebot_plugin_userinfo import EventUserInfo, UserInfo
|
||||
|
||||
from zhenxun.configs.config import NICKNAME, Config
|
||||
from zhenxun.configs.config import BotConfig, Config
|
||||
from zhenxun.configs.utils import PluginExtraData, RegisterConfig
|
||||
from zhenxun.models.ban_console import BanConsole
|
||||
from zhenxun.models.friend_user import FriendUser
|
||||
@ -24,11 +24,11 @@ __plugin_meta__ = PluginMetadata(
|
||||
name="昵称系统",
|
||||
description="区区昵称,才不想叫呢!",
|
||||
usage=f"""
|
||||
个人昵称,将替换{NICKNAME}称呼你的名称,群聊 与 私聊 昵称相互独立,全局昵称设置将更改您目前所有群聊中及私聊的昵称
|
||||
个人昵称,将替换{BotConfig.nickname}称呼你的名称,群聊 与 私聊 昵称相互独立,全局昵称设置将更改您目前所有群聊中及私聊的昵称
|
||||
指令:
|
||||
以后叫我 [昵称]: 设置当前群聊/私聊的昵称
|
||||
全局昵称设置 [昵称]: 设置当前所有群聊和私聊的昵称
|
||||
{NICKNAME}我是谁
|
||||
{BotConfig.nickname}我是谁
|
||||
""".strip(),
|
||||
extra=PluginExtraData(
|
||||
author="HibiKier",
|
||||
@ -86,25 +86,25 @@ _matcher.shortcut(
|
||||
|
||||
CALL_NAME = [
|
||||
"好啦好啦,我知道啦,{},以后就这么叫你吧",
|
||||
f"嗯嗯,{NICKNAME}" + "记住你的昵称了哦,{}",
|
||||
f"嗯嗯,{BotConfig.nickname}" + "记住你的昵称了哦,{}",
|
||||
"好突然,突然要叫你昵称什么的...{}..",
|
||||
f"{NICKNAME}" + "会好好记住{}的,放心吧",
|
||||
f"{BotConfig.nickname}" + "会好好记住{}的,放心吧",
|
||||
"好..好.,那窝以后就叫你{}了.",
|
||||
]
|
||||
|
||||
REMIND = [
|
||||
"我肯定记得你啊,你是{}啊",
|
||||
"我不会忘记你的,你也不要忘记我!{}",
|
||||
f"哼哼,{NICKNAME}" + "记忆力可是很好的,{}",
|
||||
f"哼哼,{BotConfig.nickname}" + "记忆力可是很好的,{}",
|
||||
"嗯?你是失忆了嘛...{}..",
|
||||
f"不要小看{NICKNAME}" + "的记忆力啊!笨蛋{}!QAQ",
|
||||
f"不要小看{BotConfig.nickname}" + "的记忆力啊!笨蛋{}!QAQ",
|
||||
"哎?{}..怎么了吗..突然这样问..",
|
||||
]
|
||||
|
||||
CANCEL = [
|
||||
f"呜..{NICKNAME}" + "睡一觉就会忘记的..和梦一样..{}",
|
||||
f"呜..{BotConfig.nickname}" + "睡一觉就会忘记的..和梦一样..{}",
|
||||
"窝知道了..{}..",
|
||||
f"是{NICKNAME}" + "哪里做的不好嘛..好吧..晚安{}",
|
||||
f"是{BotConfig.nickname}" + "哪里做的不好嘛..好吧..晚安{}",
|
||||
"呃,{},下次我绝对绝对绝对不会再忘记你!",
|
||||
"可..可恶!{}!太可恶了!呜",
|
||||
]
|
||||
@ -152,9 +152,9 @@ def CheckNickname():
|
||||
logger.debug(
|
||||
"昵称设置禁止字符: [{word}]", "昵称设置", session=session
|
||||
)
|
||||
await MessageUtils.build_message(f"字符 [{x}] 为禁止字符!").finish(
|
||||
at_sender=True
|
||||
)
|
||||
await MessageUtils.build_message(
|
||||
f"字符 [{word}] 为禁止字符!"
|
||||
).finish(at_sender=True)
|
||||
|
||||
return Depends(dependency)
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@ from nonebot.adapters.onebot.v12 import (
|
||||
from nonebot.plugin import PluginMetadata
|
||||
from nonebot_plugin_alconna import At
|
||||
|
||||
from zhenxun.configs.config import NICKNAME, Config
|
||||
from zhenxun.configs.config import BotConfig, Config
|
||||
from zhenxun.configs.path_config import DATA_PATH, IMAGE_PATH
|
||||
from zhenxun.configs.utils import PluginExtraData, RegisterConfig, Task
|
||||
from zhenxun.models.fg_request import FgRequest
|
||||
@ -44,7 +44,7 @@ __plugin_meta__ = PluginMetadata(
|
||||
RegisterConfig(
|
||||
module="invite_manager",
|
||||
key="message",
|
||||
value=f"请不要未经同意就拉{NICKNAME}入群!告辞!",
|
||||
value=f"请不要未经同意就拉{BotConfig.nickname}入群!告辞!",
|
||||
help="强制拉群后进群回复的内容",
|
||||
),
|
||||
RegisterConfig(
|
||||
|
||||
@ -11,7 +11,7 @@ from nonebot.plugin import PluginMetadata
|
||||
from nonebot_plugin_apscheduler import scheduler
|
||||
from nonebot_plugin_session import EventSession
|
||||
|
||||
from zhenxun.configs.config import NICKNAME, Config
|
||||
from zhenxun.configs.config import BotConfig, Config
|
||||
from zhenxun.configs.utils import PluginExtraData, RegisterConfig
|
||||
from zhenxun.models.fg_request import FgRequest
|
||||
from zhenxun.models.friend_user import FriendUser
|
||||
@ -78,7 +78,6 @@ async def _(bot: v12Bot | v11Bot, event: FriendRequestEvent, session: EventSessi
|
||||
# age = str(user["age"])
|
||||
comment = event.comment
|
||||
if superuser:
|
||||
superuser = int(superuser)
|
||||
await MessageUtils.build_message(
|
||||
f"*****一份好友申请*****\n"
|
||||
f"昵称:{nickname}({event.user_id})\n"
|
||||
@ -165,15 +164,14 @@ async def _(bot: v12Bot | v11Bot, event: GroupRequestEvent, session: EventSessio
|
||||
target=event.group_id,
|
||||
)
|
||||
nickname = await FriendUser.get_user_name(str(event.user_id))
|
||||
await Text(
|
||||
f"*****一份入群申请*****\n"
|
||||
f"申请人:{nickname}({event.user_id})\n"
|
||||
f"群聊:{event.group_id}\n"
|
||||
f"邀请日期:{datetime.now().replace(microsecond=0)}"
|
||||
).send_to(target=TargetQQPrivate(user_id=superuser), bot=bot)
|
||||
await PlatformUtils.send_superuser(
|
||||
bot,
|
||||
f"*****一份入群申请*****\n申请人:{nickname}({event.user_id})\n群聊:{event.group_id}\n邀请日期:{datetime.now().replace(microsecond=0)}",
|
||||
superuser,
|
||||
)
|
||||
await bot.send_private_msg(
|
||||
user_id=event.user_id,
|
||||
message=f"想要邀请我偷偷入群嘛~已经提醒{NICKNAME}的管理员大人了\n"
|
||||
message=f"想要邀请我偷偷入群嘛~已经提醒{BotConfig.nickname}的管理员大人了\n"
|
||||
"请确保已经群主或群管理沟通过!\n"
|
||||
"等待管理员处理吧!",
|
||||
)
|
||||
|
||||
@ -11,7 +11,7 @@ from nonebot.plugin import PluginMetadata
|
||||
from nonebot.rule import to_me
|
||||
from nonebot_plugin_session import EventSession
|
||||
|
||||
from zhenxun.configs.config import NICKNAME
|
||||
from zhenxun.configs.config import BotConfig
|
||||
from zhenxun.configs.utils import PluginExtraData
|
||||
from zhenxun.services.log import logger
|
||||
from zhenxun.utils.enum import PluginType
|
||||
@ -48,11 +48,13 @@ RESTART_FILE = Path() / "restart.sh"
|
||||
|
||||
@_matcher.got(
|
||||
"flag",
|
||||
prompt=f"确定是否重启{NICKNAME}?确定请回复[是|好|确定](重启失败咱们将失去联系,请谨慎!)",
|
||||
prompt=f"确定是否重启{BotConfig.nickname}?确定请回复[是|好|确定](重启失败咱们将失去联系,请谨慎!)",
|
||||
)
|
||||
async def _(bot: Bot, session: EventSession, flag: str = ArgStr("flag")):
|
||||
if flag.lower() in ["true", "是", "好", "确定", "确定是"]:
|
||||
await MessageUtils.build_message(f"开始重启{NICKNAME}..请稍等...").send()
|
||||
await MessageUtils.build_message(
|
||||
f"开始重启{BotConfig.nickname}..请稍等..."
|
||||
).send()
|
||||
with open(RESTART_MARK, "w", encoding="utf8") as f:
|
||||
f.write(f"{bot.self_id} {session.id1}")
|
||||
logger.info("开始重启真寻...", "重启", session=session)
|
||||
@ -90,7 +92,7 @@ async def _(bot: Bot):
|
||||
bot_id, session_id = f.read().split()
|
||||
if bot := nonebot.get_bot(bot_id):
|
||||
if target := PlatformUtils.get_target(bot, session_id):
|
||||
await MessageUtils.build_message(f"{NICKNAME}已成功重启!").send(
|
||||
target, bot=bot
|
||||
)
|
||||
await MessageUtils.build_message(
|
||||
f"{BotConfig.nickname}已成功重启!"
|
||||
).send(target, bot=bot)
|
||||
RESTART_MARK.unlink()
|
||||
|
||||
@ -2,7 +2,7 @@ import nonebot
|
||||
from nonebot.plugin import PluginMetadata
|
||||
from nonebot_plugin_apscheduler import scheduler
|
||||
|
||||
from zhenxun.configs.config import NICKNAME
|
||||
from zhenxun.configs.config import BotConfig
|
||||
from zhenxun.configs.path_config import IMAGE_PATH
|
||||
from zhenxun.configs.utils import PluginExtraData, Task
|
||||
from zhenxun.models.task_info import TaskInfo
|
||||
@ -60,7 +60,10 @@ async def _():
|
||||
)
|
||||
async def _():
|
||||
message = MessageUtils.build_message(
|
||||
[f"{NICKNAME}要睡觉了,你们也要早点睡呀", IMAGE_PATH / "zhenxun" / "sleep.jpg"]
|
||||
[
|
||||
f"{BotConfig.nickname}要睡觉了,你们也要早点睡呀",
|
||||
IMAGE_PATH / "zhenxun" / "sleep.jpg",
|
||||
]
|
||||
)
|
||||
await broadcast_group(
|
||||
message,
|
||||
|
||||
@ -9,7 +9,7 @@ import pytz
|
||||
from nonebot.drivers import Driver
|
||||
from nonebot_plugin_htmlrender import template_to_pic
|
||||
|
||||
from zhenxun.configs.config import NICKNAME, Config
|
||||
from zhenxun.configs.config import BotConfig, Config
|
||||
from zhenxun.configs.path_config import IMAGE_PATH, TEMPLATE_PATH
|
||||
from zhenxun.models.sign_log import SignLog
|
||||
from zhenxun.models.sign_user import SignUser
|
||||
@ -150,7 +150,9 @@ async def _generate_card(
|
||||
level = "8"
|
||||
interpolation = 0
|
||||
await info_img.text((0, 0), f"· 好感度等级:{level} [{lik2relation[level]}]")
|
||||
await info_img.text((0, 20), f"· {NICKNAME}对你的态度:{level2attitude[level]}")
|
||||
await info_img.text(
|
||||
(0, 20), f"· {BotConfig.nickname}对你的态度:{level2attitude[level]}"
|
||||
)
|
||||
await info_img.text((0, 40), f"· 距离升级还差 {interpolation:.2f} 好感度")
|
||||
|
||||
bar_bk = BuildImage(220, 20, background=SIGN_RESOURCE_PATH / "bar_white.png")
|
||||
@ -214,7 +216,9 @@ async def _generate_card(
|
||||
f"好感度:{user.impression:.2f}", size=30
|
||||
)
|
||||
watermark = await BuildImage.build_text_image(
|
||||
f"{NICKNAME}@{datetime.now().year}", size=15, font_color=(155, 155, 155)
|
||||
f"{BotConfig.nickname}@{datetime.now().year}",
|
||||
size=15,
|
||||
font_color=(155, 155, 155),
|
||||
)
|
||||
today_data = BuildImage(300, 300, color=(255, 255, 255, 0), font_size=20)
|
||||
if is_card_view:
|
||||
@ -390,13 +394,13 @@ async def _generate_html_card(
|
||||
else:
|
||||
uid = "XXXX XXXX XXXX"
|
||||
level, next_impression, previous_impression = get_level_and_next_impression(
|
||||
impression
|
||||
float(user.impression)
|
||||
)
|
||||
interpolation = next_impression - impression
|
||||
if level == "9":
|
||||
level = "8"
|
||||
interpolation = 0
|
||||
message = f"{NICKNAME}希望你天天开心!"
|
||||
message = f"{BotConfig.nickname}希望你开心!"
|
||||
hour = datetime.now().hour
|
||||
if hour > 6 and hour < 10:
|
||||
message = random.choice(MORNING_MESSAGE)
|
||||
@ -416,19 +420,22 @@ async def _generate_html_card(
|
||||
"name": nickname,
|
||||
"uid": uid,
|
||||
"sign_count": f"{user.sign_count}",
|
||||
"message": message,
|
||||
"message": f"{BotConfig.nickname}说: {message}",
|
||||
"cur_impression": f"{user.impression:.2f}",
|
||||
"impression": f"好感度+{_impression}",
|
||||
"gold": f"金币+{gold}",
|
||||
"gift": gift,
|
||||
"level": f"{level} [{lik2relation[level]}]",
|
||||
"attitude": level2attitude[level],
|
||||
"attitude": f"{BotConfig.nickname}对你的态度: {level2attitude[level]}",
|
||||
"interpolation": f"{interpolation:.2f}",
|
||||
"heart2": [1 for _ in range(int(level))],
|
||||
"heart1": [1 for _ in range(9 - int(level))],
|
||||
"process": process,
|
||||
"process": process * 100,
|
||||
"date": str(now.replace(microsecond=0)),
|
||||
"font_size": 45,
|
||||
}
|
||||
if len(nickname) > 6:
|
||||
data["font_size"] = 27
|
||||
_type = "sign"
|
||||
if is_card_view:
|
||||
_type = "view"
|
||||
|
||||
@ -16,7 +16,7 @@ from nonebot_plugin_alconna import (
|
||||
)
|
||||
from nonebot_plugin_session import EventSession
|
||||
|
||||
from zhenxun.configs.config import NICKNAME
|
||||
from zhenxun.configs.config import BotConfig
|
||||
from zhenxun.configs.utils import PluginExtraData
|
||||
from zhenxun.models.group_console import GroupConsole
|
||||
from zhenxun.services.log import logger
|
||||
@ -191,11 +191,16 @@ async def _(bot: Bot, session: EventSession, arparma: Arparma, group_id: int):
|
||||
group_list = [g["group_id"] for g in await bot.get_group_list()]
|
||||
if group_id not in group_list:
|
||||
logger.debug("群组不存在", "退群", session=session, target=group_id)
|
||||
await MessageUtils.build_message(f"{NICKNAME}未在该群组中...").finish()
|
||||
await MessageUtils.build_message(
|
||||
f"{BotConfig.nickname}未在该群组中..."
|
||||
).finish()
|
||||
try:
|
||||
await bot.set_group_leave(group_id=group_id)
|
||||
logger.info(
|
||||
f"{NICKNAME}退出群组成功", "退群", session=session, target=group_id
|
||||
f"{BotConfig.nickname}退出群组成功",
|
||||
"退群",
|
||||
session=session,
|
||||
target=group_id,
|
||||
)
|
||||
await MessageUtils.build_message(f"退出群组 {group_id} 成功!").send()
|
||||
await GroupConsole.filter(group_id=group_id).delete()
|
||||
|
||||
@ -3,7 +3,7 @@ from fastapi import APIRouter
|
||||
from nonebot.adapters.onebot.v11 import ActionFailed
|
||||
from tortoise.functions import Count
|
||||
|
||||
from zhenxun.configs.config import NICKNAME
|
||||
from zhenxun.configs.config import BotConfig
|
||||
from zhenxun.models.ban_console import BanConsole
|
||||
from zhenxun.models.chat_history import ChatHistory
|
||||
from zhenxun.models.fg_request import FgRequest
|
||||
@ -133,7 +133,7 @@ async def _() -> Result:
|
||||
"friend_count": f_count,
|
||||
"group_count": g_count,
|
||||
}
|
||||
return Result.ok(data, f"{NICKNAME}带来了最新的数据!")
|
||||
return Result.ok(data, f"{BotConfig.nickname}带来了最新的数据!")
|
||||
|
||||
|
||||
@router.get(
|
||||
@ -177,7 +177,7 @@ async def _() -> Result:
|
||||
except Exception as e:
|
||||
logger.error("调用API错误", "/get_request", e=e)
|
||||
return Result.fail(f"{type(e)}: {e}")
|
||||
return Result.ok(req_result, f"{NICKNAME}带来了最新的数据!")
|
||||
return Result.ok(req_result, f"{BotConfig.nickname}带来了最新的数据!")
|
||||
|
||||
|
||||
@router.post(
|
||||
@ -234,9 +234,7 @@ async def _(parma: HandleRequest) -> Result:
|
||||
else:
|
||||
await GroupConsole.update_or_create(
|
||||
group_id=req.group_id,
|
||||
defaults={
|
||||
"group_flag": 1,
|
||||
},
|
||||
defaults={"group_flag": 1},
|
||||
)
|
||||
else:
|
||||
return Result.warning_("未找到此Id请求...")
|
||||
|
||||
@ -13,13 +13,38 @@ if platform.system() == "Linux":
|
||||
)
|
||||
|
||||
|
||||
# 回复消息名称
|
||||
NICKNAME: str = "小真寻"
|
||||
class BotConfigSetting:
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.__nickname: str = ""
|
||||
self.__system_proxy: str | None = None
|
||||
|
||||
@property
|
||||
def nickname(self) -> str:
|
||||
return self.__nickname
|
||||
|
||||
@nickname.setter
|
||||
def nickname(self, v: str):
|
||||
self.__nickname = v
|
||||
|
||||
@property
|
||||
def system_proxy(self) -> str | None:
|
||||
return self.__system_proxy
|
||||
|
||||
@system_proxy.setter
|
||||
def system_proxy(self, v: str):
|
||||
self.__system_proxy = v
|
||||
|
||||
|
||||
# 回复消息名称
|
||||
NICKNAME: str = ""
|
||||
|
||||
# 代理,例如 "http://127.0.0.1:7890"
|
||||
# 如果是WLS 可以 f"http://{hostip}:7890" 使用寄主机的代理
|
||||
SYSTEM_PROXY: str | None = None # 全局代理
|
||||
|
||||
# 数据库(必要)
|
||||
# 如果填写了bind就不需要再填写后面的字段了#)
|
||||
# 示例:"bind": "postgres://user:password@127.0.0.1:5432/database"
|
||||
bind: str = ""
|
||||
bind: str = "" # 数据库连接链接
|
||||
sql_name: str = "postgres"
|
||||
user: str = "" # 数据用户名
|
||||
password: str = "" # 数据库密码
|
||||
@ -27,9 +52,6 @@ address: str = "" # 数据库地址
|
||||
port: str = "" # 数据库端口
|
||||
database: str = "" # 数据库名称
|
||||
|
||||
# 代理,例如 "http://127.0.0.1:7890"
|
||||
# 如果是WLS 可以 f"http://{hostip}:7890" 使用寄主机的代理
|
||||
SYSTEM_PROXY: str | None = "http://127.0.0.1:7890" # 全局代理
|
||||
|
||||
|
||||
Config = ConfigsManager(Path() / "data" / "configs" / "plugins2config.yaml")
|
||||
|
||||
BotConfig = BotConfigSetting()
|
||||
|
||||
@ -6,7 +6,7 @@ from nonebot.rule import to_me
|
||||
from nonebot_plugin_alconna import UniMsg
|
||||
from nonebot_plugin_session import EventSession
|
||||
|
||||
from zhenxun.configs.config import NICKNAME, Config
|
||||
from zhenxun.configs.config import BotConfig, Config
|
||||
from zhenxun.configs.utils import PluginExtraData, RegisterConfig
|
||||
from zhenxun.models.friend_user import FriendUser
|
||||
from zhenxun.models.group_member_info import GroupInfoUser
|
||||
@ -20,7 +20,7 @@ __plugin_meta__ = PluginMetadata(
|
||||
name="AI",
|
||||
description="屑Ai",
|
||||
usage=f"""
|
||||
与{NICKNAME}普普通通的对话吧!
|
||||
与{BotConfig.nickname}普普通通的对话吧!
|
||||
""".strip(),
|
||||
extra=PluginExtraData(
|
||||
author="HibiKier",
|
||||
|
||||
@ -5,7 +5,7 @@ import re
|
||||
import ujson as json
|
||||
from nonebot_plugin_alconna import UniMessage, UniMsg
|
||||
|
||||
from zhenxun.configs.config import NICKNAME, Config
|
||||
from zhenxun.configs.config import BotConfig, Config
|
||||
from zhenxun.configs.path_config import DATA_PATH, IMAGE_PATH
|
||||
from zhenxun.services.log import logger
|
||||
from zhenxun.utils.http_utils import AsyncHttpx
|
||||
@ -154,9 +154,9 @@ async def xie_ai(text: str) -> str:
|
||||
if data["result"] == 0:
|
||||
content = data["content"]
|
||||
if "菲菲" in content:
|
||||
content = content.replace("菲菲", NICKNAME)
|
||||
content = content.replace("菲菲", BotConfig.nickname)
|
||||
if "艳儿" in content:
|
||||
content = content.replace("艳儿", NICKNAME)
|
||||
content = content.replace("艳儿", BotConfig.nickname)
|
||||
if "公众号" in content:
|
||||
content = ""
|
||||
if "{br}" in content:
|
||||
@ -188,7 +188,7 @@ def hello() -> UniMessage:
|
||||
(
|
||||
"哦豁?!",
|
||||
"你好!Ov<",
|
||||
f"库库库,呼唤{NICKNAME}做什么呢",
|
||||
f"库库库,呼唤{BotConfig.nickname}做什么呢",
|
||||
"我在呢!",
|
||||
"呼呼,叫俺干嘛",
|
||||
)
|
||||
@ -206,7 +206,7 @@ def no_result() -> UniMessage:
|
||||
random.choice(
|
||||
[
|
||||
"你在说啥子?",
|
||||
f"纯洁的{NICKNAME}没听懂",
|
||||
f"纯洁的{BotConfig.nickname}没听懂",
|
||||
"下次再告诉你(下次一定)",
|
||||
"你觉得我听懂了吗?嗯?",
|
||||
"我!不!知!道!",
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import random
|
||||
import time
|
||||
|
||||
from zhenxun.configs.config import NICKNAME
|
||||
from zhenxun.configs.config import BotConfig
|
||||
from zhenxun.models.ban_console import BanConsole
|
||||
|
||||
|
||||
@ -15,14 +15,14 @@ class AiMessageManager:
|
||||
"你是只会说这一句话吗?",
|
||||
"[*],你发我也发!",
|
||||
"[uname],[*]",
|
||||
f"救命!有笨蛋一直给{NICKNAME}发一样的话!",
|
||||
f"救命!有笨蛋一直给{BotConfig.nickname}发一样的话!",
|
||||
"这句话你已经给我发了{}次了,再发就生气!",
|
||||
]
|
||||
self._repeat_message = [
|
||||
f"请不要学{NICKNAME}说话",
|
||||
f"为什么要一直学{NICKNAME}说话?",
|
||||
f"请不要学{BotConfig.nickname}说话",
|
||||
f"为什么要一直学{BotConfig.nickname}说话?",
|
||||
"你再学!你再学我就生气了!",
|
||||
f"呜呜,你是想欺负{NICKNAME}嘛..",
|
||||
f"呜呜,你是想欺负{BotConfig.nickname}嘛..",
|
||||
"[uname]不要再学我说话了!",
|
||||
"再学我说话,我就把你拉进黑名单(生气",
|
||||
"你再学![uname]是个笨蛋!",
|
||||
|
||||
@ -7,7 +7,7 @@ from nonebot.plugin import PluginMetadata
|
||||
from nonebot_plugin_alconna import Alconna, Args, Arparma, Match, Option, on_alconna
|
||||
from nonebot_plugin_session import EventSession
|
||||
|
||||
from zhenxun.configs.config import NICKNAME
|
||||
from zhenxun.configs.config import BotConfig
|
||||
from zhenxun.configs.utils import PluginExtraData, RegisterConfig
|
||||
from zhenxun.services.log import logger
|
||||
from zhenxun.utils.enum import PluginType
|
||||
@ -79,7 +79,7 @@ __plugin_meta__ = PluginMetadata(
|
||||
),
|
||||
RegisterConfig(
|
||||
key="WARNING_RESULT",
|
||||
value=f"请注意对{NICKNAME}的发言内容",
|
||||
value=f"请注意对{BotConfig.nickname}的发言内容",
|
||||
help="口头警告内容",
|
||||
default_value=None,
|
||||
),
|
||||
@ -202,7 +202,7 @@ async def _():
|
||||
|
||||
关于敏感词:
|
||||
|
||||
记住不要骂{NICKNAME}就对了!
|
||||
记住不要骂{BotConfig.nickname}就对了!
|
||||
""".strip()
|
||||
max_width = 0
|
||||
for m in text.split("\n"):
|
||||
|
||||
@ -5,9 +5,7 @@ from nonebot.adapters.onebot.v11 import Bot as v11Bot
|
||||
from nonebot.adapters.onebot.v12 import Bot as v12Bot
|
||||
from nonebot_plugin_alconna import Image, UniMessage
|
||||
|
||||
from zhenxun.configs.config import NICKNAME
|
||||
from zhenxun.services.log import logger
|
||||
from zhenxun.utils._build_image import BuildImage
|
||||
from zhenxun.utils.http_utils import AsyncHttpx
|
||||
from zhenxun.utils.message import MessageUtils
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@ from nonebot_plugin_alconna import Image as alcImg
|
||||
from nonebot_plugin_alconna import UniMsg
|
||||
from nonebot_plugin_session import EventSession
|
||||
|
||||
from zhenxun.configs.config import NICKNAME, Config
|
||||
from zhenxun.configs.config import BotConfig, Config
|
||||
from zhenxun.configs.path_config import TEMP_PATH
|
||||
from zhenxun.configs.utils import PluginExtraData, RegisterConfig, Task
|
||||
from zhenxun.models.task_info import TaskInfo
|
||||
@ -112,7 +112,7 @@ async def _(message: UniMsg, event: Event, session: EventSession):
|
||||
image_list.append(m.url)
|
||||
if not plain_text and not image_list:
|
||||
return
|
||||
if plain_text and plain_text.startswith(f"@可爱的{NICKNAME}"):
|
||||
if plain_text and plain_text.startswith(f"@可爱的{BotConfig.nickname}"):
|
||||
await MessageUtils.build_message("复制粘贴的虚空艾特?").send(reply_to=True)
|
||||
if image_list:
|
||||
img_hash = await get_download_image_hash(image_list[0], group_id)
|
||||
|
||||
@ -12,7 +12,7 @@ from nonebot_plugin_alconna import Alconna, Args, Arparma, At, Match, Option, on
|
||||
from nonebot_plugin_apscheduler import scheduler
|
||||
from nonebot_plugin_session import EventSession
|
||||
|
||||
from zhenxun.configs.config import NICKNAME
|
||||
from zhenxun.configs.config import BotConfig
|
||||
from zhenxun.configs.utils import PluginCdBlock, PluginExtraData, RegisterConfig
|
||||
from zhenxun.services.log import logger
|
||||
from zhenxun.utils.depends import GetConfig, UserName
|
||||
@ -298,7 +298,7 @@ async def _(
|
||||
try:
|
||||
await MessageUtils.build_message(
|
||||
[
|
||||
f"{NICKNAME}的节日红包过时了,一共开启了 "
|
||||
f"{BotConfig.nickname}的节日红包过时了,一共开启了 "
|
||||
f"{len(festive_red_bag.open_user)}"
|
||||
f" 个红包,共 {sum(festive_red_bag.open_user.values())} 金币\n",
|
||||
rank_image,
|
||||
@ -314,10 +314,10 @@ async def _(
|
||||
except JobLookupError:
|
||||
pass
|
||||
await group_red_bag.add_red_bag(
|
||||
f"{NICKNAME}的红包",
|
||||
f"{BotConfig.nickname}的红包",
|
||||
amount,
|
||||
num,
|
||||
NICKNAME,
|
||||
BotConfig.nickname,
|
||||
FESTIVE_KEY,
|
||||
_uuid,
|
||||
platform=session.platform,
|
||||
@ -335,7 +335,7 @@ async def _(
|
||||
)
|
||||
await MessageUtils.build_message(
|
||||
[
|
||||
f"{NICKNAME}发起了节日金币红包\n金额: {amount}\n数量: {num}\n",
|
||||
f"{BotConfig.nickname}发起了节日金币红包\n金额: {amount}\n数量: {num}\n",
|
||||
image_result,
|
||||
]
|
||||
).send(target=target, bot=bot)
|
||||
|
||||
@ -8,7 +8,7 @@ from nonebot.adapters import Bot
|
||||
from nonebot.exception import ActionFailed
|
||||
from nonebot_plugin_alconna import UniMessage
|
||||
|
||||
from zhenxun.configs.config import NICKNAME, Config
|
||||
from zhenxun.configs.config import BotConfig, Config
|
||||
from zhenxun.configs.path_config import IMAGE_PATH
|
||||
from zhenxun.models.user_console import UserConsole
|
||||
from zhenxun.utils.image_utils import BuildImage
|
||||
@ -58,7 +58,7 @@ class RedBagManager:
|
||||
try:
|
||||
await MessageUtils.build_message(
|
||||
[
|
||||
f"{NICKNAME}的节日红包过时了,一共开启了 "
|
||||
f"{BotConfig.nickname}的节日红包过时了,一共开启了 "
|
||||
f"{len(red_bag.open_user)}"
|
||||
f" 个红包,共 {sum(red_bag.open_user.values())} 金币\n",
|
||||
rank_image,
|
||||
@ -92,7 +92,7 @@ class RedBagManager:
|
||||
rank_image = await festive_red_bag.build_amount_rank(rank_num, platform)
|
||||
return MessageUtils.build_message(
|
||||
[
|
||||
f"{NICKNAME}的节日红包过时了,一共开启了 "
|
||||
f"{BotConfig.nickname}的节日红包过时了,一共开启了 "
|
||||
f"{len(festive_red_bag.open_user)}"
|
||||
f" 个红包,共 {sum(festive_red_bag.open_user.values())} 金币\n",
|
||||
rank_image,
|
||||
|
||||
@ -5,7 +5,7 @@ from nonebot_plugin_alconna import Image as alcImage
|
||||
from nonebot_plugin_alconna import UniMsg
|
||||
from nonebot_plugin_session import EventSession
|
||||
|
||||
from zhenxun.configs.config import NICKNAME
|
||||
from zhenxun.configs.config import BotConfig
|
||||
from zhenxun.configs.utils import PluginExtraData
|
||||
from zhenxun.models.ban_console import BanConsole
|
||||
from zhenxun.services.log import logger
|
||||
@ -48,7 +48,7 @@ async def _(bot: Bot, session: EventSession, message: UniMsg):
|
||||
try:
|
||||
await PlatformUtils.ban_user(bot, session.id1, group_id, duration)
|
||||
await MessageUtils.build_message(
|
||||
f"检测到恶意刷屏,{NICKNAME}要把你关进小黑屋!"
|
||||
f"检测到恶意刷屏,{BotConfig.nickname}要把你关进小黑屋!"
|
||||
).send(at_sender=True)
|
||||
mute_manage.reset(session.id1, group_id)
|
||||
logger.info(f"检测刷屏 被禁言 {duration} 分钟", "禁言检查", session=session)
|
||||
|
||||
@ -2,7 +2,7 @@ from nonebot.plugin import PluginMetadata
|
||||
from nonebot_plugin_alconna import Alconna, Args, Arparma, Match, Option, on_alconna
|
||||
from nonebot_plugin_session import EventSession
|
||||
|
||||
from zhenxun.configs.config import NICKNAME
|
||||
from zhenxun.configs.config import BotConfig
|
||||
from zhenxun.configs.utils import PluginExtraData, RegisterConfig
|
||||
from zhenxun.services.log import logger
|
||||
from zhenxun.utils.enum import PluginType
|
||||
@ -15,7 +15,7 @@ __plugin_meta__ = PluginMetadata(
|
||||
name="刷屏禁言",
|
||||
description="刷屏禁言相关操作",
|
||||
usage="""
|
||||
刷屏禁言相关操作,需要 {NICKNAME} 有群管理员权限
|
||||
刷屏禁言相关操作,需要 {BotConfig.nickname} 有群管理员权限
|
||||
指令:
|
||||
设置刷屏: 查看当前设置
|
||||
-c [count]: 检测最大次数
|
||||
|
||||
@ -6,7 +6,7 @@ from nonebot.plugin import PluginMetadata
|
||||
from nonebot_plugin_alconna import UniMsg
|
||||
from nonebot_plugin_session import EventSession
|
||||
|
||||
from zhenxun.configs.config import NICKNAME
|
||||
from zhenxun.configs.config import BotConfig
|
||||
from zhenxun.configs.utils import PluginExtraData
|
||||
from zhenxun.services.log import logger
|
||||
from zhenxun.utils.depends import UserName
|
||||
@ -56,7 +56,7 @@ async def _(
|
||||
await MessageUtils.build_message(
|
||||
random.choice(
|
||||
[
|
||||
f"让{NICKNAME}看看是什么结果!答案是:‘{random_text}’",
|
||||
f"让{BotConfig.nickname}看看是什么结果!答案是:‘{random_text}’",
|
||||
f"根据命运的指引,接下来{user_name} ‘{random_text}’ 会比较好",
|
||||
f"祈愿被回应了!是 ‘{random_text}’!",
|
||||
f"结束了,{user_name},命运之轮停在了 ‘{random_text}’!",
|
||||
|
||||
@ -8,7 +8,7 @@ from nonebot_plugin_alconna import At, UniMessage
|
||||
from nonebot_plugin_apscheduler import scheduler
|
||||
from pydantic import BaseModel
|
||||
|
||||
from zhenxun.configs.config import NICKNAME, Config
|
||||
from zhenxun.configs.config import BotConfig, Config
|
||||
from zhenxun.models.group_member_info import GroupInfoUser
|
||||
from zhenxun.models.user_console import UserConsole
|
||||
from zhenxun.utils.enum import GoldHandle
|
||||
@ -278,7 +278,7 @@ class RussianManage:
|
||||
random.choice(
|
||||
[
|
||||
f"不要打扰 {russian.player1[1]} 和 {russian.player2[1]} 的决斗啊!",
|
||||
f"给我好好做好一个观众!不然{NICKNAME}就要生气了",
|
||||
f"给我好好做好一个观众!不然{BotConfig.nickname}就要生气了",
|
||||
f"不要捣乱啊baka{uname}!",
|
||||
]
|
||||
)
|
||||
@ -429,7 +429,7 @@ class RussianManage:
|
||||
f"\t累计败场:{loser.fail_count}\n"
|
||||
f"\t累计输掉金币:{loser.lose_money}\n"
|
||||
f"-------------------\n"
|
||||
f"哼哼,{NICKNAME}从中收取了 {float(rand)}%({fee}金币) 作为手续费!\n"
|
||||
f"哼哼,{BotConfig.nickname}从中收取了 {float(rand)}%({fee}金币) 作为手续费!\n"
|
||||
f"子弹排列:{russian.bullet_arr}",
|
||||
padding=10,
|
||||
color="#f9f6f2",
|
||||
|
||||
@ -4,7 +4,7 @@ from nonebot.rule import to_me
|
||||
from nonebot_plugin_alconna import Alconna, Args, Arparma, Match, on_alconna
|
||||
from nonebot_plugin_session import EventSession
|
||||
|
||||
from zhenxun.configs.config import NICKNAME
|
||||
from zhenxun.configs.config import BotConfig
|
||||
from zhenxun.configs.utils import BaseBlock, PluginExtraData, RegisterConfig
|
||||
from zhenxun.services.log import logger
|
||||
from zhenxun.utils.message import MessageUtils
|
||||
@ -83,7 +83,7 @@ async def arg_handle(
|
||||
result, status_code = await get_price(name)
|
||||
except FileNotFoundError:
|
||||
await MessageUtils.build_message(
|
||||
f'请先对{NICKNAME}说"设置cookie"来设置cookie!'
|
||||
f'请先对{BotConfig.nickname}说"设置cookie"来设置cookie!'
|
||||
).send(at_sender=True)
|
||||
if status_code in [996, 997, 998]:
|
||||
await MessageUtils.build_message(result).finish()
|
||||
|
||||
@ -16,7 +16,7 @@ from nonebot_plugin_alconna import (
|
||||
)
|
||||
from nonebot_plugin_session import EventSession
|
||||
|
||||
from zhenxun.configs.config import NICKNAME
|
||||
from zhenxun.configs.config import BotConfig
|
||||
from zhenxun.configs.utils import PluginCdBlock, PluginExtraData, RegisterConfig
|
||||
from zhenxun.models.sign_user import SignUser
|
||||
from zhenxun.models.user_console import UserConsole
|
||||
@ -173,7 +173,7 @@ async def _(
|
||||
local_id: Match[int],
|
||||
):
|
||||
_tags = tags.result.split("#") if tags.available else None
|
||||
if _tags and NICKNAME in _tags:
|
||||
if _tags and BotConfig.nickname in _tags:
|
||||
await MessageUtils.build_message(
|
||||
"咳咳咳,虽然我很可爱,但是我木有自己的色图~~~有的话记得发我一份呀"
|
||||
).finish()
|
||||
|
||||
@ -5,7 +5,7 @@ from pathlib import Path
|
||||
from asyncpg import UniqueViolationError
|
||||
from nonebot_plugin_alconna import UniMessage
|
||||
|
||||
from zhenxun.configs.config import NICKNAME, Config
|
||||
from zhenxun.configs.config import BotConfig, Config
|
||||
from zhenxun.configs.path_config import IMAGE_PATH, TEMP_PATH
|
||||
from zhenxun.services.log import logger
|
||||
from zhenxun.utils.http_utils import AsyncHttpx
|
||||
@ -186,7 +186,7 @@ class SetuManage:
|
||||
IMAGE_PATH
|
||||
/ "luoxiang"
|
||||
/ random.choice(os.listdir(IMAGE_PATH / "luoxiang")),
|
||||
f"\n(快向{NICKNAME}签到提升好感度吧!)",
|
||||
f"\n(快向{BotConfig.nickname}签到提升好感度吧!)",
|
||||
]
|
||||
)
|
||||
return None
|
||||
|
||||
@ -5,7 +5,7 @@ from nonebot import get_driver
|
||||
from playwright.__main__ import main
|
||||
from playwright.async_api import Browser, Playwright, async_playwright
|
||||
|
||||
from zhenxun.configs.config import SYSTEM_PROXY
|
||||
from zhenxun.configs.config import BotConfig
|
||||
from zhenxun.services.log import logger
|
||||
|
||||
driver = get_driver()
|
||||
@ -45,12 +45,12 @@ def install():
|
||||
os.environ["PLAYWRIGHT_DOWNLOAD_HOST"] = (
|
||||
"https://npmmirror.com/mirrors/playwright/"
|
||||
)
|
||||
if SYSTEM_PROXY:
|
||||
os.environ["HTTPS_PROXY"] = SYSTEM_PROXY
|
||||
if BotConfig.system_proxy:
|
||||
os.environ["HTTPS_PROXY"] = BotConfig.system_proxy
|
||||
|
||||
def restore_env_variables():
|
||||
os.environ.pop("PLAYWRIGHT_DOWNLOAD_HOST", None)
|
||||
if SYSTEM_PROXY:
|
||||
if BotConfig.system_proxy:
|
||||
os.environ.pop("HTTPS_PROXY", None)
|
||||
if original_proxy is not None:
|
||||
os.environ["HTTPS_PROXY"] = original_proxy
|
||||
|
||||
@ -13,7 +13,7 @@ from nonebot_plugin_htmlrender import get_browser
|
||||
from playwright.async_api import Page
|
||||
from retrying import retry
|
||||
|
||||
from zhenxun.configs.config import SYSTEM_PROXY
|
||||
from zhenxun.configs.config import BotConfig
|
||||
from zhenxun.services.log import logger
|
||||
from zhenxun.utils.message import MessageUtils
|
||||
from zhenxun.utils.user_agent import get_user_agent
|
||||
@ -23,7 +23,7 @@ from zhenxun.utils.user_agent import get_user_agent
|
||||
|
||||
class AsyncHttpx:
|
||||
|
||||
proxy = {"http://": SYSTEM_PROXY, "https://": SYSTEM_PROXY}
|
||||
proxy = {"http://": BotConfig.system_proxy, "https://": BotConfig.system_proxy}
|
||||
|
||||
@classmethod
|
||||
@retry(stop_max_attempt_number=3)
|
||||
|
||||
@ -5,7 +5,7 @@ import nonebot
|
||||
from nonebot.adapters.onebot.v11 import Message, MessageSegment
|
||||
from nonebot_plugin_alconna import At, Image, Text, UniMessage
|
||||
|
||||
from zhenxun.configs.config import NICKNAME
|
||||
from zhenxun.configs.config import BotConfig
|
||||
from zhenxun.services.log import logger
|
||||
from zhenxun.utils._build_image import BuildImage
|
||||
|
||||
@ -81,7 +81,7 @@ class MessageUtils:
|
||||
cls,
|
||||
msg_list: list[str | Message],
|
||||
uin: str,
|
||||
name: str = f"这里是{NICKNAME}",
|
||||
name: str = f"这里是{BotConfig.nickname}",
|
||||
) -> list[dict]:
|
||||
"""生成自定义合并消息
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user