diff options
| author | 2024-03-11 16:46:23 +0800 | |
|---|---|---|
| committer | 2024-03-11 16:46:23 +0800 | |
| commit | f0c2463da050d64e1a51a9bee91684261f34272b (patch) | |
| tree | 6852d67cb451067efb0fb6e10cb75eeadaecadb0 | |
| parent | 56be89d50feadbb63eef72ccb068ceac867e871f (diff) | |
| download | infini-f0c2463da050d64e1a51a9bee91684261f34272b.tar.gz infini-f0c2463da050d64e1a51a9bee91684261f34272b.zip | |
feat(input): update input methods
| -rw-r--r-- | src/infini/input.py | 19 |
1 files 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) |
