mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-10-02 02:00:01 +08:00
🎨 代码优化
This commit is contained in:
@@ -20,7 +20,7 @@ __plugin_meta__ = PluginMetadata(
|
||||
name="AI",
|
||||
description="屑Ai",
|
||||
usage=f"""
|
||||
与{BotConfig.nickname}普普通通的对话吧!
|
||||
与{BotConfig.self_nickname}普普通通的对话吧!
|
||||
""".strip(),
|
||||
extra=PluginExtraData(
|
||||
author="HibiKier",
|
||||
|
||||
@@ -154,9 +154,9 @@ async def xie_ai(text: str) -> str:
|
||||
if data["result"] == 0:
|
||||
content = data["content"]
|
||||
if "菲菲" in content:
|
||||
content = content.replace("菲菲", BotConfig.nickname)
|
||||
content = content.replace("菲菲", BotConfig.self_nickname)
|
||||
if "艳儿" in content:
|
||||
content = content.replace("艳儿", BotConfig.nickname)
|
||||
content = content.replace("艳儿", BotConfig.self_nickname)
|
||||
if "公众号" in content:
|
||||
content = ""
|
||||
if "{br}" in content:
|
||||
@@ -188,7 +188,7 @@ def hello() -> UniMessage:
|
||||
(
|
||||
"哦豁?!",
|
||||
"你好!Ov<",
|
||||
f"库库库,呼唤{BotConfig.nickname}做什么呢",
|
||||
f"库库库,呼唤{BotConfig.self_nickname}做什么呢",
|
||||
"我在呢!",
|
||||
"呼呼,叫俺干嘛",
|
||||
)
|
||||
@@ -206,7 +206,7 @@ def no_result() -> UniMessage:
|
||||
random.choice(
|
||||
[
|
||||
"你在说啥子?",
|
||||
f"纯洁的{BotConfig.nickname}没听懂",
|
||||
f"纯洁的{BotConfig.self_nickname}没听懂",
|
||||
"下次再告诉你(下次一定)",
|
||||
"你觉得我听懂了吗?嗯?",
|
||||
"我!不!知!道!",
|
||||
|
||||
@@ -15,14 +15,14 @@ class AiMessageManager:
|
||||
"你是只会说这一句话吗?",
|
||||
"[*],你发我也发!",
|
||||
"[uname],[*]",
|
||||
f"救命!有笨蛋一直给{BotConfig.nickname}发一样的话!",
|
||||
f"救命!有笨蛋一直给{BotConfig.self_nickname}发一样的话!",
|
||||
"这句话你已经给我发了{}次了,再发就生气!",
|
||||
]
|
||||
self._repeat_message = [
|
||||
f"请不要学{BotConfig.nickname}说话",
|
||||
f"为什么要一直学{BotConfig.nickname}说话?",
|
||||
f"请不要学{BotConfig.self_nickname}说话",
|
||||
f"为什么要一直学{BotConfig.self_nickname}说话?",
|
||||
"你再学!你再学我就生气了!",
|
||||
f"呜呜,你是想欺负{BotConfig.nickname}嘛..",
|
||||
f"呜呜,你是想欺负{BotConfig.self_nickname}嘛..",
|
||||
"[uname]不要再学我说话了!",
|
||||
"再学我说话,我就把你拉进黑名单(生气",
|
||||
"你再学![uname]是个笨蛋!",
|
||||
|
||||
@@ -79,7 +79,7 @@ __plugin_meta__ = PluginMetadata(
|
||||
),
|
||||
RegisterConfig(
|
||||
key="WARNING_RESULT",
|
||||
value=f"请注意对{BotConfig.nickname}的发言内容",
|
||||
value=f"请注意对{BotConfig.self_nickname}的发言内容",
|
||||
help="口头警告内容",
|
||||
default_value=None,
|
||||
),
|
||||
@@ -202,7 +202,7 @@ async def _():
|
||||
|
||||
关于敏感词:
|
||||
|
||||
记住不要骂{BotConfig.nickname}就对了!
|
||||
记住不要骂{BotConfig.self_nickname}就对了!
|
||||
""".strip()
|
||||
max_width = 0
|
||||
for m in text.split("\n"):
|
||||
|
||||
@@ -8,6 +8,7 @@ from nonebot_plugin_alconna import Target, Text, UniMsg
|
||||
from nonebot_plugin_session import EventSession
|
||||
from nonebot_plugin_userinfo import EventUserInfo, UserInfo
|
||||
|
||||
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
|
||||
@@ -58,14 +59,10 @@ async def _(
|
||||
if session.id1:
|
||||
message[0] = Text(str(message[0]).replace("滴滴滴-", "", 1))
|
||||
platform = PlatformUtils.get_platform(bot)
|
||||
superuser_id = None
|
||||
try:
|
||||
superuser_id = config.platform_superusers["qq"][0]
|
||||
if platform == "dodo":
|
||||
superuser_id = config.platform_superusers["dodo"][0]
|
||||
if platform == "kaiheila":
|
||||
superuser_id = config.platform_superusers["kaiheila"][0]
|
||||
if platform == "discord":
|
||||
superuser_id = config.platform_superusers["discord"][0]
|
||||
if platform:
|
||||
superuser_id = BotConfig.get_superuser(platform)
|
||||
except IndexError:
|
||||
await MessageUtils.build_message("管理员失联啦...").finish()
|
||||
if not superuser_id:
|
||||
|
||||
@@ -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"@可爱的{BotConfig.nickname}"):
|
||||
if plain_text and plain_text.startswith(f"@可爱的{BotConfig.self_nickname}"):
|
||||
await MessageUtils.build_message("复制粘贴的虚空艾特?").send(reply_to=True)
|
||||
if image_list:
|
||||
img_hash = await get_download_image_hash(image_list[0], group_id)
|
||||
|
||||
@@ -298,7 +298,7 @@ async def _(
|
||||
try:
|
||||
await MessageUtils.build_message(
|
||||
[
|
||||
f"{BotConfig.nickname}的节日红包过时了,一共开启了 "
|
||||
f"{BotConfig.self_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"{BotConfig.nickname}的红包",
|
||||
f"{BotConfig.self_nickname}的红包",
|
||||
amount,
|
||||
num,
|
||||
BotConfig.nickname,
|
||||
BotConfig.self_nickname,
|
||||
FESTIVE_KEY,
|
||||
_uuid,
|
||||
platform=session.platform,
|
||||
@@ -335,7 +335,7 @@ async def _(
|
||||
)
|
||||
await MessageUtils.build_message(
|
||||
[
|
||||
f"{BotConfig.nickname}发起了节日金币红包\n金额: {amount}\n数量: {num}\n",
|
||||
f"{BotConfig.self_nickname}发起了节日金币红包\n金额: {amount}\n数量: {num}\n",
|
||||
image_result,
|
||||
]
|
||||
).send(target=target, bot=bot)
|
||||
|
||||
@@ -58,7 +58,7 @@ class RedBagManager:
|
||||
try:
|
||||
await MessageUtils.build_message(
|
||||
[
|
||||
f"{BotConfig.nickname}的节日红包过时了,一共开启了 "
|
||||
f"{BotConfig.self_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"{BotConfig.nickname}的节日红包过时了,一共开启了 "
|
||||
f"{BotConfig.self_nickname}的节日红包过时了,一共开启了 "
|
||||
f"{len(festive_red_bag.open_user)}"
|
||||
f" 个红包,共 {sum(festive_red_bag.open_user.values())} 金币\n",
|
||||
rank_image,
|
||||
|
||||
@@ -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"检测到恶意刷屏,{BotConfig.nickname}要把你关进小黑屋!"
|
||||
f"检测到恶意刷屏,{BotConfig.self_nickname}要把你关进小黑屋!"
|
||||
).send(at_sender=True)
|
||||
mute_manage.reset(session.id1, group_id)
|
||||
logger.info(f"检测刷屏 被禁言 {duration} 分钟", "禁言检查", session=session)
|
||||
|
||||
@@ -15,7 +15,7 @@ __plugin_meta__ = PluginMetadata(
|
||||
name="刷屏禁言",
|
||||
description="刷屏禁言相关操作",
|
||||
usage="""
|
||||
刷屏禁言相关操作,需要 {BotConfig.nickname} 有群管理员权限
|
||||
刷屏禁言相关操作,需要 {BotConfig.self_nickname} 有群管理员权限
|
||||
指令:
|
||||
设置刷屏: 查看当前设置
|
||||
-c [count]: 检测最大次数
|
||||
|
||||
@@ -56,7 +56,7 @@ async def _(
|
||||
await MessageUtils.build_message(
|
||||
random.choice(
|
||||
[
|
||||
f"让{BotConfig.nickname}看看是什么结果!答案是:‘{random_text}’",
|
||||
f"让{BotConfig.self_nickname}看看是什么结果!答案是:‘{random_text}’",
|
||||
f"根据命运的指引,接下来{user_name} ‘{random_text}’ 会比较好",
|
||||
f"祈愿被回应了!是 ‘{random_text}’!",
|
||||
f"结束了,{user_name},命运之轮停在了 ‘{random_text}’!",
|
||||
|
||||
@@ -278,7 +278,7 @@ class RussianManage:
|
||||
random.choice(
|
||||
[
|
||||
f"不要打扰 {russian.player1[1]} 和 {russian.player2[1]} 的决斗啊!",
|
||||
f"给我好好做好一个观众!不然{BotConfig.nickname}就要生气了",
|
||||
f"给我好好做好一个观众!不然{BotConfig.self_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"哼哼,{BotConfig.nickname}从中收取了 {float(rand)}%({fee}金币) 作为手续费!\n"
|
||||
f"哼哼,{BotConfig.self_nickname}从中收取了 {float(rand)}%({fee}金币) 作为手续费!\n"
|
||||
f"子弹排列:{russian.bullet_arr}",
|
||||
padding=10,
|
||||
color="#f9f6f2",
|
||||
|
||||
@@ -83,7 +83,7 @@ async def arg_handle(
|
||||
result, status_code = await get_price(name)
|
||||
except FileNotFoundError:
|
||||
await MessageUtils.build_message(
|
||||
f'请先对{BotConfig.nickname}说"设置cookie"来设置cookie!'
|
||||
f'请先对{BotConfig.self_nickname}说"设置cookie"来设置cookie!'
|
||||
).send(at_sender=True)
|
||||
if status_code in [996, 997, 998]:
|
||||
await MessageUtils.build_message(result).finish()
|
||||
|
||||
@@ -173,7 +173,7 @@ async def _(
|
||||
local_id: Match[int],
|
||||
):
|
||||
_tags = tags.result.split("#") if tags.available else None
|
||||
if _tags and BotConfig.nickname in _tags:
|
||||
if _tags and BotConfig.self_nickname in _tags:
|
||||
await MessageUtils.build_message(
|
||||
"咳咳咳,虽然我很可爱,但是我木有自己的色图~~~有的话记得发我一份呀"
|
||||
).finish()
|
||||
|
||||
@@ -186,7 +186,7 @@ class SetuManage:
|
||||
IMAGE_PATH
|
||||
/ "luoxiang"
|
||||
/ random.choice(os.listdir(IMAGE_PATH / "luoxiang")),
|
||||
f"\n(快向{BotConfig.nickname}签到提升好感度吧!)",
|
||||
f"\n(快向{BotConfig.self_nickname}签到提升好感度吧!)",
|
||||
]
|
||||
)
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user