mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-07-20 13:47:15 +08:00
refactor(wechat_kf): persist sync_msg cursor under $HOME
Move the sync_msg cursor file from the project-local tmp/ dir to ~/.wechat_kf_cursors.json so it survives tmp/ cleanups and cwd changes across restarts. Aligns with the weixin channel's credentials file convention. - add wechat_kf_cursor_path config (default ~/.wechat_kf_cursors.json) - expand ~ via os.path.expanduser in the channel init - chmod the cursor file to 0o600 after each flush (no-op on Windows)
This commit is contained in:
@@ -82,9 +82,11 @@ class WechatKfChannel(ChatChannel):
|
||||
# corrupts URLs and triggers errcode 40014.
|
||||
self.client = WeChatClient(self.corp_id, self.secret)
|
||||
|
||||
# Cursor file is an internal implementation detail — fixed under
|
||||
# the project's `tmp/` dir, not exposed as a user-facing config.
|
||||
cursor_path = os.path.join("tmp", "wechat_kf_cursors.json")
|
||||
# Persist sync_msg cursor under the user's home dir by default,
|
||||
# so it survives `tmp/` cleanups and cwd changes across restarts.
|
||||
cursor_path = os.path.expanduser(
|
||||
conf().get("wechat_kf_cursor_path") or "~/.wechat_kf_cursors.json"
|
||||
)
|
||||
self.cursor_store = CursorStore(cursor_path)
|
||||
|
||||
# WeCom requires the callback HTTP response to return within ~5s,
|
||||
|
||||
Reference in New Issue
Block a user