Files
gitlab-instance-0a899031_pa…/app/services/memos.py
2026-03-12 19:50:50 -05:00

22 lines
616 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""Memos 用户创建(基于 SDK仅 nomadvip 使用)"""
from app.config import MEMOS_API, MEMOS_TOKEN
from app.sdk.memos import MemosSDK
_memos_sdk: MemosSDK | None = None
def _get_memos_sdk() -> MemosSDK:
global _memos_sdk
if _memos_sdk is None:
_memos_sdk = MemosSDK(
api_url=MEMOS_API,
token=MEMOS_TOKEN,
enabled=bool(MEMOS_API and MEMOS_TOKEN),
)
return _memos_sdk
def create_memos_user(user_id: str, password: str = "12345678"):
"""创建 Memos 用户"""
return _get_memos_sdk().create_user(user_id=user_id, password=password)