From f0c2463da050d64e1a51a9bee91684261f34272b Mon Sep 17 00:00:00 2001 From: 苏向夜 Date: Mon, 11 Mar 2024 16:46:23 +0800 Subject: feat(input): update input methods --- src/infini/input.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/infini/input.py b/src/infini/input.py index 0bbb3f2f..2a926e2a 100644 --- a/src/infini/input.py +++ b/src/infini/input.py @@ -13,16 +13,19 @@ class Input(Generic[T]): self.plain_data = plain_data self.variables = variables or {} - def get_user_id(self) -> Optional[str]: - return self.variables.get("user_id") + def get_user_id(self) -> str: + return self.variables.get("user_id", "0") def get_session_id(self) -> str: - if session_id := self.variables.get("session_id"): - return session_id - - user_id = self.variables.get("user_id", "unknown") - group_id = self.variables.get("group_id", "unknown") - return f"session_{group_id}_{user_id}" + return ( + self.variables.get("group_id") + or self.variables.get("session_id") + or self.variables.get("user_id") + or "0" + ) + + def is_tome(self) -> bool: + return bool(self.variables.get("is_tome")) def get_plain_text(self) -> str: return str(self.plain_data) -- cgit v1.2.3-70-g09d2