mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-15 06:12:53 +08:00
🐛 : 修复签到问题
This commit is contained in:
parent
167555016a
commit
487f019c89
@ -54,7 +54,7 @@ from public.bag_users t1
|
||||
"""
|
||||
|
||||
|
||||
# @driver.on_startup
|
||||
@driver.on_startup
|
||||
async def _():
|
||||
global flag
|
||||
await shop_register.load_register()
|
||||
|
||||
@ -80,14 +80,14 @@ class SignManage:
|
||||
|
||||
@classmethod
|
||||
async def sign(
|
||||
cls, session: EventSession, nickname: str, is_view_card: bool = False
|
||||
cls, session: EventSession, nickname: str, is_card_view: bool = False
|
||||
) -> Path | None:
|
||||
"""签到
|
||||
|
||||
参数:
|
||||
session: Session
|
||||
nickname: 用户昵称
|
||||
is_view_card: 是否展示卡片
|
||||
is_card_view: 是否展示卡片
|
||||
|
||||
返回:
|
||||
Path: 卡片路径
|
||||
@ -100,17 +100,15 @@ class SignManage:
|
||||
user_id=session.id1,
|
||||
defaults={"user_console": user_console, "platform": session.platform},
|
||||
)
|
||||
new_log = await SignLog.filter(user_id=session.id1).first()
|
||||
file_name = f"{user}_sign_{datetime.now().date()}.png"
|
||||
if (
|
||||
user.sign_count != 0
|
||||
or (new_log and now > new_log.create_time)
|
||||
or file_name in os.listdir(SIGN_TODAY_CARD_PATH)
|
||||
):
|
||||
path = await get_card(user, nickname, -1, user_console.gold, "")
|
||||
else:
|
||||
path = await cls._handle_sign_in(user, nickname, session, is_view_card)
|
||||
return path
|
||||
new_log = (
|
||||
await SignLog.filter(user_id=session.id1).order_by("-create_time").first()
|
||||
)
|
||||
if not is_card_view:
|
||||
if not new_log or (new_log and new_log.create_time.date() != now.date()):
|
||||
return await cls._handle_sign_in(user, nickname, session)
|
||||
return await get_card(
|
||||
user, nickname, -1, user_console.gold, "", is_card_view=is_card_view
|
||||
)
|
||||
|
||||
@classmethod
|
||||
async def _handle_sign_in(
|
||||
@ -118,7 +116,6 @@ class SignManage:
|
||||
user: SignUser,
|
||||
nickname: str,
|
||||
session: EventSession,
|
||||
is_view_card: bool,
|
||||
) -> Path:
|
||||
"""签到处理
|
||||
|
||||
@ -126,7 +123,6 @@ class SignManage:
|
||||
user: SignUser
|
||||
nickname: 用户昵称
|
||||
session: Session
|
||||
is_view_card: 是否展示卡片
|
||||
|
||||
返回:
|
||||
Path: 卡片路径
|
||||
@ -165,5 +161,4 @@ class SignManage:
|
||||
gold,
|
||||
gift,
|
||||
rand + add_probability > 0.97 or rand < specify_probability,
|
||||
is_view_card,
|
||||
)
|
||||
|
||||
@ -172,9 +172,8 @@ async def _generate_card(
|
||||
uid_img = await BuildImage.build_text_image(
|
||||
f"UID: {uid}", size=30, font_color=(255, 255, 255)
|
||||
)
|
||||
sign_count = await SignLog.filter(user_id=user.user_id).count()
|
||||
sign_day_img = await BuildImage.build_text_image(
|
||||
f"{sign_count}", size=40, font_color=(211, 64, 33)
|
||||
f"{user.sign_count}", size=40, font_color=(211, 64, 33)
|
||||
)
|
||||
lik_text1_img = await BuildImage.build_text_image("当前", size=20)
|
||||
lik_text2_img = await BuildImage.build_text_image(
|
||||
|
||||
@ -69,7 +69,10 @@ class ConfigGroup(BaseModel):
|
||||
def get(self, c: str, default: Any = None) -> Any:
|
||||
cfg = self.configs.get(c)
|
||||
if cfg is not None:
|
||||
return cfg.value
|
||||
if cfg.value is not None:
|
||||
return cfg.value
|
||||
if cfg.default_value is not None:
|
||||
return cfg.default_value
|
||||
return default
|
||||
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@ class SignLog(Model):
|
||||
|
||||
id = fields.IntField(pk=True, generated=True, auto_increment=True)
|
||||
"""自增id"""
|
||||
user_id = fields.CharField(255, unique=True, description="用户id")
|
||||
user_id = fields.CharField(255, description="用户id")
|
||||
"""用户id"""
|
||||
impression = fields.DecimalField(10, 3, default=0, description="好感度")
|
||||
"""好感度"""
|
||||
|
||||
@ -24,7 +24,7 @@ anime_data = json.load(open(DATA_PATH / "anime.json", "r", encoding="utf8"))
|
||||
|
||||
async def get_chat_result(
|
||||
message: UniMsg, user_id: str, nickname: str
|
||||
) -> Text | MessageFactory:
|
||||
) -> Text | MessageFactory | None:
|
||||
"""获取 AI 返回值,顺序: 特殊回复 -> 图灵 -> 青云客
|
||||
|
||||
参数:
|
||||
@ -54,7 +54,7 @@ async def get_chat_result(
|
||||
if not rst:
|
||||
rst = await xie_ai(text)
|
||||
if not rst:
|
||||
return no_result()
|
||||
return None
|
||||
if nickname:
|
||||
if len(nickname) < 5:
|
||||
if random.random() < 0.5:
|
||||
|
||||
@ -6,7 +6,7 @@ from pydantic import BaseModel
|
||||
from zhenxun.configs.config import Config
|
||||
from zhenxun.configs.path_config import DATA_PATH
|
||||
|
||||
base_config = Config.get("mute")
|
||||
base_config = Config.get("mute_setting")
|
||||
|
||||
|
||||
class GroupData(BaseModel):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user