feat: add daily commission history for Web 2.0.8
This commit is contained in:
+41
-3
@@ -101,6 +101,7 @@ class _Job:
|
||||
workspace: str = ""
|
||||
category: str = "general"
|
||||
due_kind: str | None = None
|
||||
commission_failure: str = ""
|
||||
|
||||
def public(self):
|
||||
operation = {"__config": "set_config", "__view": "view"}.get(self.operation, self.operation)
|
||||
@@ -450,10 +451,41 @@ class AccountWorker:
|
||||
# Attribution must not prevent an otherwise valid action.
|
||||
category = "general"
|
||||
self._attribute_task(category)
|
||||
return _method(*args, **kwargs)
|
||||
try:
|
||||
return _method(*args, **kwargs)
|
||||
except CancelledBeforeDispatch:
|
||||
raise
|
||||
except Exception:
|
||||
if category == "commissions":
|
||||
# Enrich the existing error entry, preserving the original
|
||||
# exception and its one-time reporting on the worker.
|
||||
try:
|
||||
source = args[0] if args else kwargs.get("intent", kwargs.get("action"))
|
||||
if source is None and _name == "_run_progression_intent":
|
||||
source = intent
|
||||
self._commission_failure_context(engine, source)
|
||||
except Exception:
|
||||
pass
|
||||
raise
|
||||
|
||||
setattr(engine, name, routed)
|
||||
|
||||
def _commission_failure_context(self, engine, source):
|
||||
if self._execution is None or threading.current_thread() is not getattr(self, "thread", None):
|
||||
return
|
||||
field = lambda key, default=None: source.get(key, default) if isinstance(source, dict) else getattr(source, key, default)
|
||||
payload = field("payload") or {}
|
||||
type_id = field("source_task_type_id") or field("task_type_id") or payload.get("taskTypeId")
|
||||
info = engine._commission_info(type_id)
|
||||
name = info.get("name") or type_id or "名称未记录"
|
||||
reward = (info.get("reward") or {}).get("ke")
|
||||
expected = f"标注{reward}氪金" if type(reward) in (int, float) else "标注氪金未记录"
|
||||
path = field("path", "") or ""
|
||||
kind = field("kind", "")
|
||||
action = "接取" if path.endswith("taskLoopReceive") or kind in {"quest_accept", "progression_loop_accept"} else (
|
||||
"领奖" if path.endswith("taskComplete") or kind in {"quest_complete", "progression_complete"} else "推进")
|
||||
self._execution.commission_failure = f"委托「{name}」({expected}){action}异常,结果待核对"
|
||||
|
||||
def remember(self, value):
|
||||
with self._secret_lock:
|
||||
if isinstance(value, dict):
|
||||
@@ -544,7 +576,13 @@ class AccountWorker:
|
||||
notes = getattr(getattr(self.engine, name, None), "notes", ())
|
||||
sources.append((category, [self.safe_text(note) for note in notes[:512]]))
|
||||
for category, text in route_message(self.safe_text(message), context=self._task_category(), hints=note_hints(sources)):
|
||||
self.log(text, category=category)
|
||||
level = "info"
|
||||
if category == "commissions":
|
||||
if "战斗失败" in text:
|
||||
level = "error"
|
||||
elif any(marker in text for marker in ("结果未知", "未确认", "待确认", "等待核对", "奖励未记录")):
|
||||
level = "warning"
|
||||
self.log(text, category=category, level=level)
|
||||
|
||||
def _trace_event(self, event):
|
||||
fields = [event.get("operation", "网络"), event.get("kind", "")]
|
||||
@@ -844,7 +882,7 @@ class AccountWorker:
|
||||
if (job.consuming and job.operation != "start"
|
||||
and failure_sequence == self._game_failure_sequence):
|
||||
self._execution_failed(error)
|
||||
self.log(message, category=job.category, level="error")
|
||||
self.log((job.commission_failure + ";" if job.commission_failure else "") + message, category=job.category, level="error")
|
||||
finally:
|
||||
job.payload = {}
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user