feat: 多帳號切換 + whoami,並修正版本/跨年日期比對 - #21
Merged
Merged
Conversation
- auto_version: compare versions via int tuples instead of stripping dots, which mis-ordered multi-digit segments (e.g. 0.2.15 vs 0.3.0). - get_post_index_range: compare PTT list_date (yearless M/DD) by (month, day) only, so a target date carrying a non-current year no longer fails to match. Cross-year ranges remain unsupported (noted). - Add assert-based self-checks for both. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
CI runs flake8/mypy over the whole repo. The module-level sys.modules stubbing before importing api_post triggered E402. Move it into a helper function (function-level import is exempt) and use setattr for the stub attribute to keep mypy's warn_unused_ignores happy. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Configure multiple PTT accounts with a single PTT_ACCOUNTS env var
("name=id:pw,name2=id:pw2") and switch between them at runtime without
putting passwords in the conversation.
- switch_account(name): switch to a named account and log in; remembers it
- list_accounts(): list configured account names and the current one
- extract shared login core into _perform_login()
- legacy PTT_ID/PTT_PW still supported, becomes the "default" account
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Returns the current account label (from PTT_ACCOUNTS), the real PTT ID, and login state queried directly from PyPtt. Does not report a stale ptt_id after logout, since PyPtt leaves it set. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Keep one logged-in PyPtt.Service per account in a pool; switching just repoints the active bot instead of logging out then re-logging in. A failed switch no longer destroys the working session or repoints state at the failed account, and Services that leave the pool are close()d instead of leaked (they own a daemon thread + connection). - _login_new_service builds+logs in a fresh Service, close()ing it on failure; _activate probes liveness (get_time) and re-logs a dead pooled session before repointing. - switch_account/login go through _activate; logout closes just the active Service and drops it from the pool. - list_accounts reports current=None when not actually logged in. - mcp_server closes the whole pool at exit. Addresses the switch-atomicity, Service-leak, and list_accounts false-current findings from the branch review. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
摘要
本分支累積了三塊獨立改動:
1. 修正版本比較與跨年日期比對 (
f2c4458)2. 多帳號切換 (
83d60e9)PTT_ACCOUNTS(名稱=帳號:密碼,名稱2=帳號2:密碼2)設定多組帳號,執行期切換,密碼不進對話switch_account(name):切換到指定帳號並登入,會記住當前帳號list_accounts():列出已設定帳號與目前使用中的帳號_perform_login()PTT_ID/PTT_PW,成為default帳號3.
whoami工具 (122bcf4)PTT_ACCOUNTS)、實際 PTT ID、登入狀態(直接向 PyPtt 查)ptt_id測試
test_parse_accounts.py、test_switch_account.py、test_whoami.py全數通過(9 passed)🤖 Generated with Claude Code