aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--pyproject.toml2
-rw-r--r--src/infini/input.py19
2 files changed, 12 insertions, 9 deletions
diff --git a/pyproject.toml b/pyproject.toml
index d3d5edfd..90b9718c 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
[project]
name = "infini"
-version = "2.1.2"
+version = "2.1.3"
description = "Infini 内容输入输出流框架"
authors = [
{ name = "苏向夜", email = "fu050409@163.com" },
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)