mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-15 14:22:55 +08:00
Merge branch 'main' of https://github.com/HibiKier/zhenxun_bot
This commit is contained in:
commit
42683e4f09
@ -228,7 +228,6 @@ class HelpImageBuild:
|
||||
for msg in [
|
||||
"目前支持的功能列表:",
|
||||
"可以通过 ‘帮助[功能名称]’ 来获取对应功能的使用方法",
|
||||
"或者使用 ‘详细帮助’ 来获取所有功能方法",
|
||||
]:
|
||||
text = BuildImage(
|
||||
0,
|
||||
|
||||
@ -27,6 +27,8 @@ def init_plugins_settings():
|
||||
else:
|
||||
if plugin_data := plugin_data_manager.get(matcher.plugin_name):
|
||||
if plugin_settings := plugin_data.plugin_setting:
|
||||
if (name := _module.__getattribute__("__zx_plugin_name__")) not in plugin_settings.cmd:
|
||||
plugin_settings.cmd.append(name)
|
||||
# 管理员命令
|
||||
if plugin_data.plugin_type == PluginType.ADMIN:
|
||||
admin_manager.add_admin_plugin_settings(
|
||||
|
||||
@ -15,7 +15,7 @@ from utils.browser import get_browser
|
||||
from utils.image_utils import BuildImage
|
||||
from utils.message_builder import image
|
||||
|
||||
__zx_plugin_name__ = "原神今日素材"
|
||||
__zx_plugin_name__ = "今日素材"
|
||||
__plugin_usage__ = """
|
||||
usage:
|
||||
看看原神今天要刷什么
|
||||
@ -57,8 +57,8 @@ async def _(event: MessageEvent):
|
||||
await update_image()
|
||||
await material.send(
|
||||
Message(
|
||||
image(IMAGE_PATH / "genshin" / "material" / f"{file_name}.png")
|
||||
+ "\n※ 每日素材数据来源于 genshin.pub"
|
||||
image(f"{file_name}.png", "genshin/material")
|
||||
+ "\n※ 每日素材数据来源于米游社"
|
||||
)
|
||||
)
|
||||
logger.info(
|
||||
@ -87,63 +87,14 @@ async def update_image():
|
||||
if not browser:
|
||||
logger.warning("获取 browser 失败,请部署至 linux 环境....")
|
||||
return False
|
||||
url = "https://genshin.pub/daily"
|
||||
page = await browser.new_page()
|
||||
await page.goto(url, wait_until="networkidle", timeout=10000)
|
||||
await page.set_viewport_size({"width": 2560, "height": 1080})
|
||||
await page.evaluate(
|
||||
"""
|
||||
document.getElementsByClassName('GSTitleBar_gs_titlebar__2IJqy')[0].remove();
|
||||
e = document.getElementsByClassName('GSContainer_gs_container__2FbUz')[0];
|
||||
e.setAttribute("style", "height:880px");
|
||||
"""
|
||||
)
|
||||
await page.click("button")
|
||||
div = await page.query_selector(".GSContainer_content_box__1sIXz")
|
||||
for i, card in enumerate(
|
||||
await page.query_selector_all(".GSTraitCotainer_trait_section__1f3bc")
|
||||
):
|
||||
index = 0
|
||||
type_ = "char" if not i else "weapons"
|
||||
for x in await card.query_selector_all("xpath=child::*"):
|
||||
await x.screenshot(
|
||||
path=f"{IMAGE_PATH}/genshin/material/{type_}_{index}.png",
|
||||
timeout=100000,
|
||||
)
|
||||
# 下滑两次
|
||||
for _ in range(3):
|
||||
await div.press("PageDown")
|
||||
index += 1
|
||||
# 结束后上滑至顶
|
||||
for _ in range(index * 3):
|
||||
await div.press("PageUp")
|
||||
file_list = os.listdir(f"{IMAGE_PATH}/genshin/material")
|
||||
char_img = [
|
||||
f"{IMAGE_PATH}/genshin/material/{x}"
|
||||
for x in file_list
|
||||
if x.startswith("char")
|
||||
]
|
||||
weapons_img = [
|
||||
f"{IMAGE_PATH}/genshin/material/{x}"
|
||||
for x in file_list
|
||||
if x.startswith("weapons")
|
||||
]
|
||||
char_img.sort()
|
||||
weapons_img.sort()
|
||||
height = await asyncio.get_event_loop().run_in_executor(
|
||||
None, get_background_height, weapons_img
|
||||
)
|
||||
background_img = BuildImage(1200, height + 100, color="#f6f2ee")
|
||||
current_width = 50
|
||||
for img_list in [char_img, weapons_img]:
|
||||
current_height = 20
|
||||
for img in img_list:
|
||||
x = BuildImage(0, 0, background=img)
|
||||
background_img.paste(x, (current_width, current_height))
|
||||
current_height += x.size[1]
|
||||
current_width += 600
|
||||
# url = "https://genshin.pub/daily"
|
||||
url = "https://bbs.mihoyo.com/ys/obc/channel/map/193"
|
||||
page = await browser.new_page(viewport={'width': 860, 'height': 3000})
|
||||
await page.goto(url)
|
||||
await page.wait_for_timeout(3000)
|
||||
file_name = str((datetime.now() - timedelta(hours=4)).date())
|
||||
background_img.save(f"{IMAGE_PATH}/genshin/material/{file_name}.png")
|
||||
# background_img.save(f"{IMAGE_PATH}/genshin/material/{file_name}.png")
|
||||
await page.locator('//*[@id="__layout"]/div/div[2]/div[2]/div/div[1]/div[2]/div/div').screenshot(path=f"{IMAGE_PATH}/genshin/material/{file_name}.png")
|
||||
await page.close()
|
||||
return True
|
||||
except Exception as e:
|
||||
|
||||
@ -29,7 +29,6 @@ from nonebot.params import CommandArg
|
||||
import random
|
||||
import time
|
||||
|
||||
|
||||
__zx_plugin_name__ = "金币红包"
|
||||
__plugin_usage__ = """
|
||||
usage:
|
||||
@ -64,11 +63,16 @@ __plugin_settings__ = {
|
||||
}
|
||||
__plugin_resources__ = {"prts": IMAGE_PATH}
|
||||
|
||||
|
||||
async def rule(event: GroupMessageEvent) -> bool:
|
||||
return check_on_gold_red(event)
|
||||
|
||||
|
||||
gold_redbag = on_command(
|
||||
"塞红包", aliases={"金币红包"}, priority=5, block=True, permission=GROUP
|
||||
)
|
||||
|
||||
open_ = on_command("开", aliases={"抢"}, priority=5, block=True, permission=GROUP)
|
||||
open_ = on_command("开", aliases={"抢"}, priority=5, block=True, permission=GROUP, rule=rule)
|
||||
|
||||
poke_ = on_notice(priority=6, block=False)
|
||||
|
||||
@ -85,27 +89,11 @@ festive_redbag_data = {}
|
||||
|
||||
# 阻断其他poke
|
||||
@run_preprocessor
|
||||
async def _(matcher: Matcher, event: PokeNotifyEvent):
|
||||
async def _(matcher: Matcher, event: PokeNotifyEvent, ):
|
||||
try:
|
||||
if matcher.type == "notice" and event.self_id == event.target_id:
|
||||
flag1 = True
|
||||
flag2 = True
|
||||
try:
|
||||
if festive_redbag_data[event.group_id]["user_id"]:
|
||||
if (
|
||||
event.user_id
|
||||
in festive_redbag_data[event.group_id]["open_user"]
|
||||
):
|
||||
flag1 = False
|
||||
except KeyError:
|
||||
flag1 = False
|
||||
try:
|
||||
if redbag_data[event.group_id]["user_id"]:
|
||||
if event.user_id in redbag_data[event.group_id]["open_user"]:
|
||||
flag2 = False
|
||||
except KeyError:
|
||||
flag2 = False
|
||||
if flag1 or flag2:
|
||||
flag = check_on_gold_red(event)
|
||||
if flag:
|
||||
if matcher.plugin_name == "poke":
|
||||
raise IgnoredException("目前正在抢红包...")
|
||||
else:
|
||||
@ -121,8 +109,8 @@ async def _(bot: Bot, event: GroupMessageEvent, arg: Message = CommandArg()):
|
||||
try:
|
||||
if time.time() - redbag_data[event.group_id]["time"] > 60:
|
||||
amount = (
|
||||
redbag_data[event.group_id]["amount"]
|
||||
- redbag_data[event.group_id]["open_amount"]
|
||||
redbag_data[event.group_id]["amount"]
|
||||
- redbag_data[event.group_id]["open_amount"]
|
||||
)
|
||||
await return_gold(redbag_data[event.group_id]["user_id"], event.group_id, amount)
|
||||
await gold_redbag.send(
|
||||
@ -185,43 +173,21 @@ async def _(event: GroupMessageEvent, arg: Message = CommandArg()):
|
||||
msg = arg.extract_plain_text().strip()
|
||||
msg = (
|
||||
msg.replace("!", "")
|
||||
.replace("!", "")
|
||||
.replace(",", "")
|
||||
.replace(",", "")
|
||||
.replace(".", "")
|
||||
.replace("。", "")
|
||||
.replace("!", "")
|
||||
.replace(",", "")
|
||||
.replace(",", "")
|
||||
.replace(".", "")
|
||||
.replace("。", "")
|
||||
)
|
||||
if msg:
|
||||
if "红包" not in msg:
|
||||
return
|
||||
flag1 = True
|
||||
flag2 = True
|
||||
open_flag1 = True
|
||||
open_flag2 = True
|
||||
try:
|
||||
if festive_redbag_data[event.group_id]["user_id"]:
|
||||
if event.user_id in festive_redbag_data[event.group_id]["open_user"]:
|
||||
open_flag1 = False
|
||||
except KeyError:
|
||||
open_flag1 = False
|
||||
flag1 = False
|
||||
try:
|
||||
if redbag_data[event.group_id]["user_id"]:
|
||||
if event.user_id in redbag_data[event.group_id]["open_user"]:
|
||||
open_flag2 = False
|
||||
except KeyError:
|
||||
flag2 = False
|
||||
if not flag1 and not flag2:
|
||||
await open_.finish("目前没有红包可以开...", at_sender=True)
|
||||
if open_flag1 or open_flag2:
|
||||
try:
|
||||
await open_.send(
|
||||
image(b64=await get_redbag_img(event.user_id, event.group_id)),
|
||||
at_sender=True,
|
||||
await open_.send(
|
||||
image(b64=await get_redbag_img(event.user_id, event.group_id)),
|
||||
at_sender=True,
|
||||
)
|
||||
except KeyError:
|
||||
await open_.finish("真贪心,明明已经开过这个红包了的说...", at_sender=True)
|
||||
else:
|
||||
except KeyError:
|
||||
await open_.finish("真贪心,明明已经开过这个红包了的说...", at_sender=True)
|
||||
|
||||
|
||||
@ -229,19 +195,8 @@ async def _(event: GroupMessageEvent, arg: Message = CommandArg()):
|
||||
async def _poke_(event: PokeNotifyEvent):
|
||||
global redbag_data, festive_redbag_data
|
||||
if event.self_id == event.target_id:
|
||||
flag1 = True
|
||||
flag2 = True
|
||||
try:
|
||||
if event.user_id in festive_redbag_data[event.group_id]["open_user"]:
|
||||
flag1 = False
|
||||
except KeyError:
|
||||
flag1 = False
|
||||
try:
|
||||
if event.user_id in redbag_data[event.group_id]["open_user"]:
|
||||
flag2 = False
|
||||
except KeyError:
|
||||
flag2 = False
|
||||
if not flag1 and not flag2:
|
||||
flag = check_on_gold_red(event)
|
||||
if not flag:
|
||||
return
|
||||
await poke_.send(
|
||||
image(b64=await get_redbag_img(event.user_id, event.group_id)),
|
||||
@ -331,7 +286,7 @@ async def _(bot: Bot, arg: Message = CommandArg()):
|
||||
await bot.send_group_msg(
|
||||
group_id=g,
|
||||
message=f"{NICKNAME}发起了金币红包\n金额:{amount}\n数量:{num}\n"
|
||||
+ image(
|
||||
+ image(
|
||||
b64=await generate_send_redbag_pic(int(bot.self_id), greetings)
|
||||
),
|
||||
)
|
||||
@ -342,13 +297,13 @@ async def _(bot: Bot, arg: Message = CommandArg()):
|
||||
|
||||
# 红包数据初始化
|
||||
def init_redbag(
|
||||
user_id: int,
|
||||
group_id: int,
|
||||
nickname: str,
|
||||
amount: int,
|
||||
num: int,
|
||||
bot_self_id: int,
|
||||
mode: int = 0,
|
||||
user_id: int,
|
||||
group_id: int,
|
||||
nickname: str,
|
||||
amount: int,
|
||||
num: int,
|
||||
bot_self_id: int,
|
||||
mode: int = 0,
|
||||
):
|
||||
global redbag_data, festive_redbag_data
|
||||
data = redbag_data if mode == 0 else festive_redbag_data
|
||||
@ -428,3 +383,27 @@ async def end_festive_redbag(bot: Bot, group_id: int):
|
||||
)
|
||||
await bot.send_group_msg(group_id=group_id, message=message)
|
||||
festive_redbag_data[group_id] = {}
|
||||
|
||||
|
||||
def check_on_gold_red(event) -> bool:
|
||||
flag1 = True
|
||||
flag2 = True
|
||||
try:
|
||||
if festive_redbag_data[event.group_id]["user_id"]:
|
||||
if (
|
||||
event.user_id
|
||||
in festive_redbag_data[event.group_id]["open_user"]
|
||||
):
|
||||
flag1 = False
|
||||
except KeyError:
|
||||
flag1 = False
|
||||
try:
|
||||
if redbag_data[event.group_id]["user_id"]:
|
||||
if event.user_id in redbag_data[event.group_id]["open_user"]:
|
||||
flag2 = False
|
||||
except KeyError:
|
||||
flag2 = False
|
||||
if flag1 or flag2:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 88 KiB After Width: | Height: | Size: 98 KiB |
@ -13,7 +13,7 @@
|
||||
<div class="transition"></div>
|
||||
<div class="wrapper">
|
||||
<main class="des">
|
||||
<p>可以通过 ‘帮助[功能名称]’ 来获取对应功能的使用方法。 或者使用 ‘详细帮助’ 来获取所有功能方法。</p>
|
||||
<p>可以通过 ‘帮助[功能名称]’ 来获取对应功能的使用方法。</p>
|
||||
<p style="color:red;">注:横线字功能被群管理员禁用,浅色字代表功能正在维护 真寻机器人免费开源,如果你在任何渠道付费购买了真寻机器人,请退款。</p>
|
||||
</main>
|
||||
<div class="content">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user