This commit is contained in:
Your Name
2026-07-23 17:56:25 +08:00
parent a05dae8412
commit 4970d8f8d3
4262 changed files with 735221 additions and 0 deletions
@@ -0,0 +1,38 @@
"""本系统当前托管中的账号 UID 注册表。
用途:避免两个都在本系统托管的账号互相自动回复,形成无限回环——
这种高频来回发送是触发抖音风控(7911)/业务拒绝(8004)的常见根因。
"""
import logging
logger = logging.getLogger("douyin_im.hosted_registry")
_HOSTED_UIDS: set[int] = set()
def register(uid) -> None:
try:
u = int(uid)
except (TypeError, ValueError):
return
if u:
_HOSTED_UIDS.add(u)
logger.info(f"Registered hosted uid {u} (total={len(_HOSTED_UIDS)})")
def unregister(uid) -> None:
try:
u = int(uid)
except (TypeError, ValueError):
return
_HOSTED_UIDS.discard(u)
logger.info(f"Unregistered hosted uid {u} (total={len(_HOSTED_UIDS)})")
def is_hosted(uid) -> bool:
try:
u = int(uid)
except (TypeError, ValueError):
return False
return u in _HOSTED_UIDS