mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-10-22 12:40:09 +08:00
update v0.0.5.0
This commit is contained in:
@@ -6,6 +6,7 @@ from .group_user_checkin import (
|
||||
)
|
||||
from nonebot.typing import T_State
|
||||
from nonebot.adapters.cqhttp import Bot, GroupMessageEvent
|
||||
from utils.manager import plugins2cd_manager
|
||||
from nonebot.adapters.cqhttp.permission import GROUP
|
||||
from utils.message_builder import image
|
||||
from nonebot import on_command
|
||||
@@ -20,13 +21,30 @@ try:
|
||||
except ModuleNotFoundError:
|
||||
import json
|
||||
|
||||
__plugin_name__ = "签到"
|
||||
__plugin_usage__ = (
|
||||
"用法:\n"
|
||||
"对我说 “签到” 来签到\n"
|
||||
"“我的签到” 来获取历史签到信息\n"
|
||||
"“好感度排行” 来查看当前好感度前十的伙伴\n"
|
||||
"/ 签到时有 3% 概率 * 2 /"
|
||||
__zx_plugin_name__ = "签到"
|
||||
__plugin_usage__ = """
|
||||
usage:
|
||||
每日签到
|
||||
会影响色图概率和开箱次数,以及签到的随机道具获取
|
||||
指令:
|
||||
签到
|
||||
我的签到
|
||||
好感度排行
|
||||
好感度总排行
|
||||
* 签到时有 3% 概率 * 2 *
|
||||
""".strip()
|
||||
__plugin_des__ = "每日签到,证明你在这里"
|
||||
__plugin_cmd__ = ["签到", "我的签到", "好感度排行", "好感度总排行"]
|
||||
__plugin_version__ = 0.1
|
||||
__plugin_author__ = "HibiKier"
|
||||
__plugin_settings__ = {
|
||||
"level": 5,
|
||||
"default_status": True,
|
||||
"limit_superuser": False,
|
||||
"cmd": ["签到"],
|
||||
}
|
||||
plugins2cd_manager.add_cd_limit(
|
||||
'sign_in',
|
||||
)
|
||||
|
||||
_file = Path(f"{DATA_PATH}/not_show_sign_rank_user.json")
|
||||
|
||||
@@ -7,7 +7,6 @@ SIGN_TODAY_CARD_PATH = Path(IMAGE_PATH) / 'sign' / 'today_card'
|
||||
SIGN_BORDER_PATH = Path(SIGN_RESOURCE_PATH) / 'border'
|
||||
SIGN_BACKGROUND_PATH = Path(SIGN_RESOURCE_PATH) / 'background'
|
||||
|
||||
SIGN_TODAY_CARD_PATH.mkdir(exist_ok=True, parents=True)
|
||||
SIGN_BORDER_PATH.mkdir(exist_ok=True, parents=True)
|
||||
SIGN_BACKGROUND_PATH.mkdir(exist_ok=True, parents=True)
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@ import random
|
||||
import aiohttp
|
||||
import math
|
||||
import asyncio
|
||||
import os
|
||||
import secrets
|
||||
import os
|
||||
|
||||
|
||||
async def group_user_check_in(
|
||||
@@ -183,9 +183,6 @@ async def _pst(users: list, impressions: list, groups: list):
|
||||
except AttributeError:
|
||||
user_name = f"我名字呢?"
|
||||
user_name = user_name if len(user_name) < 11 else user_name[:10] + "..."
|
||||
impression = (
|
||||
str(impression)[:4] if len(str(impression)) > 4 else impression
|
||||
)
|
||||
try:
|
||||
async with session.get(
|
||||
f"http://q1.qlogo.cn/g?b=qq&nk={user}&s=160", timeout=5
|
||||
@@ -201,7 +198,7 @@ async def _pst(users: list, impressions: list, groups: list):
|
||||
bk.text((5, int((100 - font_h) / 2)), f"{idx}.")
|
||||
bk.paste(ava, (55, int((100 - 50) / 2)), True)
|
||||
bk.text((120, int((100 - font_h) / 2)), f"{user_name}")
|
||||
bk.text((460, int((100 - font_h) / 2)), f"[{impression}]")
|
||||
bk.text((460, int((100 - font_h) / 2)), f"[{impression:.2f}]")
|
||||
col_img.paste(bk)
|
||||
A.paste(col_img, (width, 0))
|
||||
lens -= 33
|
||||
|
||||
+40
-14
@@ -20,6 +20,7 @@ from typing import Optional, List
|
||||
from nonebot import Driver
|
||||
from io import BytesIO
|
||||
import asyncio
|
||||
import random
|
||||
import nonebot
|
||||
import aiohttp
|
||||
import os
|
||||
@@ -31,6 +32,7 @@ driver: Driver = nonebot.get_driver()
|
||||
@driver.on_startup
|
||||
async def init_image():
|
||||
SIGN_RESOURCE_PATH.mkdir(parents=True, exist_ok=True)
|
||||
SIGN_TODAY_CARD_PATH.mkdir(exist_ok=True, parents=True)
|
||||
await GroupInfoUser.add_member_info(114514, 114514, "", datetime.min, 0)
|
||||
_u = await GroupInfoUser.get_member_info(114514, 114514)
|
||||
if _u.uid is None:
|
||||
@@ -57,15 +59,26 @@ async def get_card(
|
||||
) -> MessageSegment:
|
||||
user_id = user.user_qq
|
||||
date = datetime.now().date()
|
||||
_type = 'view' if is_card_view else 'sign'
|
||||
card_file = Path(SIGN_TODAY_CARD_PATH) / f"{user_id}_{user.belonging_group}_{_type}_{date}.png"
|
||||
_type = "view" if is_card_view else "sign"
|
||||
card_file = (
|
||||
Path(SIGN_TODAY_CARD_PATH)
|
||||
/ f"{user_id}_{user.belonging_group}_{_type}_{date}.png"
|
||||
)
|
||||
if card_file.exists():
|
||||
return image(f"{user_id}_{user.belonging_group}_{_type}_{date}.png", "sign/today_card")
|
||||
return image(
|
||||
f"{user_id}_{user.belonging_group}_{_type}_{date}.png", "sign/today_card"
|
||||
)
|
||||
else:
|
||||
if add_impression == -1:
|
||||
card_file = Path(SIGN_TODAY_CARD_PATH) / f"{user_id}_{user.belonging_group}_view_{date}.png"
|
||||
card_file = (
|
||||
Path(SIGN_TODAY_CARD_PATH)
|
||||
/ f"{user_id}_{user.belonging_group}_view_{date}.png"
|
||||
)
|
||||
if card_file.exists():
|
||||
return image(f"{user_id}_{user.belonging_group}_view_{date}.png", "sign/today_card")
|
||||
return image(
|
||||
f"{user_id}_{user.belonging_group}_view_{date}.png",
|
||||
"sign/today_card",
|
||||
)
|
||||
is_card_view = True
|
||||
ava = BytesIO(await _get_pic(user_id))
|
||||
uid = await GroupInfoUser.get_group_member_uid(
|
||||
@@ -110,7 +123,7 @@ def _generate_card(
|
||||
ava_border = CreateImg(
|
||||
140,
|
||||
140,
|
||||
background=SIGN_BORDER_PATH / 'ava_border_01.png',
|
||||
background=SIGN_BORDER_PATH / "ava_border_01.png",
|
||||
)
|
||||
ava = CreateImg(102, 102, background=ava_bytes)
|
||||
ava.circle()
|
||||
@@ -142,15 +155,22 @@ def _generate_card(
|
||||
True,
|
||||
)
|
||||
font_size = 30
|
||||
if '好感度双倍加持卡' in gift:
|
||||
if "好感度双倍加持卡" in gift:
|
||||
font_size = 20
|
||||
gift_border = CreateImg(
|
||||
270, 100, background=SIGN_BORDER_PATH / "gift_border_02.png", font_size=font_size
|
||||
270,
|
||||
100,
|
||||
background=SIGN_BORDER_PATH / "gift_border_02.png",
|
||||
font_size=font_size,
|
||||
)
|
||||
gift_border.text((0, 0), gift, center_type="center")
|
||||
|
||||
bk = CreateImg(
|
||||
876, 424, background=SIGN_BACKGROUND_PATH / "background_01.jpg", font_size=25
|
||||
876,
|
||||
424,
|
||||
background=SIGN_BACKGROUND_PATH
|
||||
/ random.choice(os.listdir(SIGN_BACKGROUND_PATH)),
|
||||
font_size=25,
|
||||
)
|
||||
A = CreateImg(876, 274, background=SIGN_RESOURCE_PATH / "white.png")
|
||||
line = CreateImg(2, 180, color="black")
|
||||
@@ -226,8 +246,11 @@ def _generate_card(
|
||||
f"上次签到日期:{'从未' if user.checkin_time_last == datetime.min else user.checkin_time_last.date()}",
|
||||
)
|
||||
today_data.text((0, 25), f"总金币:{gold}")
|
||||
today_data.text((0, 50), f'色图概率:{(70 + user.impression if user.impression < 100 else 100):.2f}%')
|
||||
today_data.text((0, 75), f'开箱次数:{(20 + int(user.impression / 3))}')
|
||||
today_data.text(
|
||||
(0, 50),
|
||||
f"色图概率:{(70 + user.impression if user.impression < 100 else 100):.2f}%",
|
||||
)
|
||||
today_data.text((0, 75), f"开箱次数:{(20 + int(user.impression / 3))}")
|
||||
_type = "view"
|
||||
else:
|
||||
A.paste(gift_border, (570, 140), True)
|
||||
@@ -268,8 +291,12 @@ def _generate_card(
|
||||
bk.paste(today_sign_text_img, (550, 180), True)
|
||||
bk.paste(today_data, (580, 220), True)
|
||||
bk.paste(watermark, (15, 400), True)
|
||||
bk.save(SIGN_TODAY_CARD_PATH / f"{user_id}_{user.belonging_group}_{_type}_{data}.png")
|
||||
return image(f"{user_id}_{user.belonging_group}_{_type}_{data}.png", "sign/today_card")
|
||||
bk.save(
|
||||
SIGN_TODAY_CARD_PATH / f"{user_id}_{user.belonging_group}_{_type}_{data}.png"
|
||||
)
|
||||
return image(
|
||||
f"{user_id}_{user.belonging_group}_{_type}_{data}.png", "sign/today_card"
|
||||
)
|
||||
|
||||
|
||||
def generate_progress_bar_pic():
|
||||
@@ -330,4 +357,3 @@ def clear_sign_data_pic():
|
||||
for file in os.listdir(SIGN_TODAY_CARD_PATH):
|
||||
if str(date) not in file:
|
||||
os.remove(SIGN_TODAY_CARD_PATH / file)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user