Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修改星穹铁道实训/宇宙通知逻辑 #230

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/nonebot_plugin_mystool/myb_missions_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class BaseMission:
"""
米游币任务基类
"""
NAME = ""
name = ""
"""米游社分区名字"""
GIDS = 0
FID = 0
Expand Down Expand Up @@ -385,7 +385,7 @@ class GenshinImpactMission(BaseMission):
"""
原神 米游币任务
"""
NAME = "原神"
name = "原神"
GIDS = 2
FID = 26

Expand All @@ -394,7 +394,7 @@ class HonkaiImpact3Mission(BaseMission):
"""
崩坏3 米游币任务
"""
NAME = "崩坏3"
name = "崩坏3"
GIDS = 1
FID = 1

Expand All @@ -403,7 +403,7 @@ class HoukaiGakuen2Mission(BaseMission):
"""
崩坏学园2 米游币任务
"""
NAME = "崩坏学园2"
name = "崩坏学园2"
GIDS = 3
FID = 30

Expand All @@ -412,7 +412,7 @@ class TearsOfThemisMission(BaseMission):
"""
未定事件簿 米游币任务
"""
NAME = "未定事件簿"
name = "未定事件簿"
GIDS = 4
FID = 37

Expand All @@ -421,7 +421,7 @@ class StarRailMission(BaseMission):
"""
崩坏:星穹铁道 米游币任务
"""
NAME = "崩坏:星穹铁道"
name = "崩坏:星穹铁道"
GIDS = 6
FID = 52

Expand All @@ -430,7 +430,7 @@ class BBSMission(BaseMission):
"""
大别野 米游币任务
"""
NAME = "综合"
name = "综合"
GIDS = 5
# TODO: bbs fid暂时未知

Expand All @@ -439,7 +439,7 @@ class ZenlessZoneZero(BaseMission):
"""
绝区零 米游币任务
"""
NAME = "绝区零"
name = "绝区零"
GIDS = 8
# TODO: fid暂时未知

Expand Down
22 changes: 13 additions & 9 deletions src/nonebot_plugin_mystool/plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import asyncio
import threading
from typing import Union, Optional, Type, Iterable, Dict
from datetime import datetime, time

from nonebot import on_command, get_adapters
from nonebot.adapters.onebot.v11 import MessageSegment as OneBotV11MessageSegment, Adapter as OneBotV11Adapter, \
Expand Down Expand Up @@ -538,7 +539,7 @@ async def starrail_note_check(user: UserData, user_ids: Iterable[str], matcher:
if note.current_stamina >= account.user_stamina_threshold:
# 防止重复提醒
if not starrail_notice.current_stamina_full:
if note.current_stamina >= 180:
if note.current_stamina >= note.max_stamina:
starrail_notice.current_stamina_full = True
msg += '❕您的开拓力已经溢出\n'
do_notice = True
Expand All @@ -552,21 +553,24 @@ async def starrail_note_check(user: UserData, user_ids: Iterable[str], matcher:
starrail_notice.current_stamina_full = False

# 每日实训状态提醒
if note.current_train_score == note.max_train_score:
if note.current_train_score != note.max_train_score:
# 防止重复提醒
if not starrail_notice.current_train_score:
starrail_notice.current_train_score = True
msg += '❕您的每日实训已完成\n'
#if not starrail_notice.current_train_score:
if not starrail_notice.current_train_score \
and _conf.preference.notice_time: #注意此处添加notice_time是为了防止每日首次推送通知在4:00后一段时间
starrail_notice.current_train_score = True #notice_time = plan_time +1h
msg += '❕您的每日实训未完成\n' #通知逻辑变动后,如不添加notice_time,便笺检查在xx:20,便笺检查间隔1h,则每日首次通知在04:20
do_notice = True
else:
starrail_notice.current_train_score = False

# 每周模拟宇宙积分提醒
if note.current_rogue_score == note.max_rogue_score:
if note.current_rogue_score != note.max_rogue_score:
# 防止重复提醒
if not starrail_notice.current_rogue_score:
if not starrail_notice.current_rogue_score \
and _conf.preference.notice_time: #notice_time同理
starrail_notice.current_rogue_score = True
msg += '❕您的模拟宇宙积分已经打满了\n\n'
msg += '❕您的模拟宇宙积分还没打满\n\n'
do_notice = True
else:
starrail_notice.current_rogue_score = False
Expand All @@ -576,7 +580,7 @@ async def starrail_note_check(user: UserData, user_ids: Iterable[str], matcher:

msg += "❖星穹铁道·实时便笺❖" \
f"\n🆔账户 {account.bbs_uid}" \
f"\n⏳开拓力数量:{note.current_stamina} / 180" \
f"\n⏳开拓力数量:{note.current_stamina} / {note.max_stamina}" \
f"\n⏱开拓力{note.stamina_recover_text}" \
f"\n📒每日实训:{note.current_train_score} / {note.max_train_score}" \
f"\n📅每日委托:{note.accepted_expedition_num} / 4" \
Expand Down
10 changes: 9 additions & 1 deletion src/nonebot_plugin_mystool/plugin_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
import json
import os
from datetime import time, timedelta
from datetime import time, timedelta, datetime
from json import JSONDecodeError
from pathlib import Path
from typing import Union, Optional, Tuple, Any, Dict, TYPE_CHECKING, AbstractSet, \
Expand Down Expand Up @@ -119,6 +119,14 @@ def _(cls, v: Optional[Path]):
elif not os.access(absolute_path, os.W_OK):
logger.warning(f"程序没有写入日志文件 {absolute_path} 的权限")
return v

@property
def notice_time(self) -> bool:
now_time = datetime.now().time()
note_time = datetime.strptime(self.plan_time, "%H:%M")
note_time = note_time + timedelta(hours=1)
return now_time > note_time.time()



class GoodListImageConfig(BaseModel):
Expand Down
Loading