PyPtt 2.3.5__tar.gz → 2.3.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. {pyptt-2.3.5 → pyptt-2.3.6}/PKG-INFO +1 -1
  2. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt/PTT.py +3 -0
  3. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt/__init__.py +1 -1
  4. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt/_api_loginout.py +2 -0
  5. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt/exceptions.py +10 -0
  6. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt/lang_en_US.py +8 -0
  7. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt/lang_zh_TW.py +6 -0
  8. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt.egg-info/PKG-INFO +1 -1
  9. {pyptt-2.3.5 → pyptt-2.3.6}/LICENSE +0 -0
  10. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt/_api_bucket.py +0 -0
  11. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt/_api_call_status.py +0 -0
  12. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt/_api_change_pw.py +0 -0
  13. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt/_api_comment.py +0 -0
  14. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt/_api_del_post.py +0 -0
  15. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt/_api_get_board_info.py +0 -0
  16. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt/_api_get_board_list.py +0 -0
  17. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt/_api_get_bottom_post_list.py +0 -0
  18. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt/_api_get_favourite_board.py +0 -0
  19. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt/_api_get_newest_index.py +0 -0
  20. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt/_api_get_post.py +0 -0
  21. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt/_api_get_post_index.py +0 -0
  22. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt/_api_get_post_list.py +0 -0
  23. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt/_api_get_time.py +0 -0
  24. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt/_api_get_user.py +0 -0
  25. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt/_api_get_waterball.py +0 -0
  26. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt/_api_give_money.py +0 -0
  27. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt/_api_has_new_mail.py +0 -0
  28. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt/_api_mail.py +0 -0
  29. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt/_api_mark_post.py +0 -0
  30. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt/_api_post.py +0 -0
  31. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt/_api_reply_post.py +0 -0
  32. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt/_api_search_user.py +0 -0
  33. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt/_api_set_board_title.py +0 -0
  34. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt/_api_set_signature_file.py +0 -0
  35. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt/_api_util.py +0 -0
  36. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt/_uao/LICENSE +0 -0
  37. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt/_uao/__init__.py +0 -0
  38. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt/_uao/b2u.py +0 -0
  39. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt/_uao/u2b.py +0 -0
  40. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt/api_server.py +0 -0
  41. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt/check_value.py +0 -0
  42. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt/command.py +0 -0
  43. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt/config.py +0 -0
  44. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt/connect_core.py +0 -0
  45. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt/data_type.py +0 -0
  46. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt/i18n.py +0 -0
  47. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt/lib_util.py +0 -0
  48. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt/log.py +0 -0
  49. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt/screens.py +0 -0
  50. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt/service.py +0 -0
  51. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt/ssl_config.py +0 -0
  52. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt.egg-info/SOURCES.txt +0 -0
  53. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt.egg-info/dependency_links.txt +0 -0
  54. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt.egg-info/requires.txt +0 -0
  55. {pyptt-2.3.5 → pyptt-2.3.6}/PyPtt.egg-info/top_level.txt +0 -0
  56. {pyptt-2.3.5 → pyptt-2.3.6}/README.md +0 -0
  57. {pyptt-2.3.5 → pyptt-2.3.6}/pyproject.toml +0 -0
  58. {pyptt-2.3.5 → pyptt-2.3.6}/setup.cfg +0 -0
  59. {pyptt-2.3.5 → pyptt-2.3.6}/setup.py +0 -0
  60. {pyptt-2.3.5 → pyptt-2.3.6}/tests/test_backup_effective.py +0 -0
  61. {pyptt-2.3.5 → pyptt-2.3.6}/tests/test_backup_param.py +0 -0
  62. {pyptt-2.3.5 → pyptt-2.3.6}/tests/test_bucket.py +0 -0
  63. {pyptt-2.3.5 → pyptt-2.3.6}/tests/test_change_pw.py +0 -0
  64. {pyptt-2.3.5 → pyptt-2.3.6}/tests/test_comment.py +0 -0
  65. {pyptt-2.3.5 → pyptt-2.3.6}/tests/test_connect_core_timeout.py +0 -0
  66. {pyptt-2.3.5 → pyptt-2.3.6}/tests/test_del_post.py +0 -0
  67. {pyptt-2.3.5 → pyptt-2.3.6}/tests/test_del_post_unit.py +0 -0
  68. {pyptt-2.3.5 → pyptt-2.3.6}/tests/test_exceptions.py +0 -0
  69. {pyptt-2.3.5 → pyptt-2.3.6}/tests/test_fast_post.py +0 -0
  70. {pyptt-2.3.5 → pyptt-2.3.6}/tests/test_get_board_info.py +0 -0
  71. {pyptt-2.3.5 → pyptt-2.3.6}/tests/test_get_board_list.py +0 -0
  72. {pyptt-2.3.5 → pyptt-2.3.6}/tests/test_get_bottom_post_list.py +0 -0
  73. {pyptt-2.3.5 → pyptt-2.3.6}/tests/test_get_content_formula.py +0 -0
  74. {pyptt-2.3.5 → pyptt-2.3.6}/tests/test_get_favourite_boards.py +0 -0
  75. {pyptt-2.3.5 → pyptt-2.3.6}/tests/test_get_mail.py +0 -0
  76. {pyptt-2.3.5 → pyptt-2.3.6}/tests/test_get_newest_index.py +0 -0
  77. {pyptt-2.3.5 → pyptt-2.3.6}/tests/test_get_post.py +0 -0
  78. {pyptt-2.3.5 → pyptt-2.3.6}/tests/test_get_post_list.py +0 -0
  79. {pyptt-2.3.5 → pyptt-2.3.6}/tests/test_get_post_list_parser.py +0 -0
  80. {pyptt-2.3.5 → pyptt-2.3.6}/tests/test_get_post_parser.py +0 -0
  81. {pyptt-2.3.5 → pyptt-2.3.6}/tests/test_get_time.py +0 -0
  82. {pyptt-2.3.5 → pyptt-2.3.6}/tests/test_get_user.py +0 -0
  83. {pyptt-2.3.5 → pyptt-2.3.6}/tests/test_get_waterball.py +0 -0
  84. {pyptt-2.3.5 → pyptt-2.3.6}/tests/test_give_money.py +0 -0
  85. {pyptt-2.3.5 → pyptt-2.3.6}/tests/test_half_dead_connection.py +0 -0
  86. {pyptt-2.3.5 → pyptt-2.3.6}/tests/test_i18n.py +0 -0
  87. {pyptt-2.3.5 → pyptt-2.3.6}/tests/test_incremental_parity.py +0 -0
  88. {pyptt-2.3.5 → pyptt-2.3.6}/tests/test_init.py +0 -0
  89. {pyptt-2.3.5 → pyptt-2.3.6}/tests/test_logger.py +0 -0
  90. {pyptt-2.3.5 → pyptt-2.3.6}/tests/test_login_logout.py +0 -0
  91. {pyptt-2.3.5 → pyptt-2.3.6}/tests/test_mail_send_and_del.py +0 -0
  92. {pyptt-2.3.5 → pyptt-2.3.6}/tests/test_mark_post.py +0 -0
  93. {pyptt-2.3.5 → pyptt-2.3.6}/tests/test_parse_query_post.py +0 -0
  94. {pyptt-2.3.5 → pyptt-2.3.6}/tests/test_post.py +0 -0
  95. {pyptt-2.3.5 → pyptt-2.3.6}/tests/test_post_anonymous.py +0 -0
  96. {pyptt-2.3.5 → pyptt-2.3.6}/tests/test_pyte_parity.py +0 -0
  97. {pyptt-2.3.5 → pyptt-2.3.6}/tests/test_reply_post.py +0 -0
  98. {pyptt-2.3.5 → pyptt-2.3.6}/tests/test_search_user.py +0 -0
  99. {pyptt-2.3.5 → pyptt-2.3.6}/tests/test_service.py +0 -0
  100. {pyptt-2.3.5 → pyptt-2.3.6}/tests/test_set_board_title.py +0 -0
  101. {pyptt-2.3.5 → pyptt-2.3.6}/tests/test_set_signature_file.py +0 -0
  102. {pyptt-2.3.5 → pyptt-2.3.6}/tests/test_uao_codec.py +0 -0
  103. {pyptt-2.3.5 → pyptt-2.3.6}/tests/test_vt100_parser.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PyPtt
3
- Version: 2.3.5
3
+ Version: 2.3.6
4
4
  Summary: PyPtt github: https://github.com/PyPtt/PyPtt
5
5
  Author-email: CodingMan <pttcodingman@gmail.com>
6
6
  License: GNU Lesser General Public License v3 (LGPLv3)
@@ -230,6 +230,7 @@ class API:
230
230
 
231
231
  Raises:
232
232
  LoginError: 登入失敗。
233
+ TwoFactorAuthRequired: 偵測到兩階段驗證畫面,PyPtt 無法自動完成驗證。
233
234
  WrongIDorPassword: 帳號或密碼錯誤。
234
235
  OnlySecureConnection: 只能使用安全連線。
235
236
  ResetYourContactEmail: 請先至信箱設定連絡信箱。
@@ -242,6 +243,8 @@ class API:
242
243
  try:
243
244
  ptt_bot.login(
244
245
  ptt_id='ptt_id', ptt_pw='ptt_pw', kick_other_session=True)
246
+ except PyPtt.TwoFactorAuthRequired:
247
+ print('偵測到兩階段驗證,請先手動登入完成驗證')
245
248
  except PyPtt.LoginError:
246
249
  print('登入失敗')
247
250
  except PyPtt.WrongIDorPassword:
@@ -1,4 +1,4 @@
1
- __version__ = '2.3.5'
1
+ __version__ = '2.3.6'
2
2
  __author__ = 'CodingMan'
3
3
  __email__ = 'pttcodingman@gmail.com'
4
4
 
@@ -97,6 +97,8 @@ def login(api, ptt_id: str, ptt_pw: str, kick_other_session: bool) -> None:
97
97
  connect_core.TargetUnit('密碼正確'),
98
98
  connect_core.TargetUnit('您想刪除其他重複登入的連線嗎', response=kick_other_login_response),
99
99
  connect_core.TargetUnit('◆ 您的註冊申請單尚在處理中', response=command.enter, handler=register_processing),
100
+ # 需排在「任意鍵」等泛用 catch-all 之前, 否則會被搶先命中而吃不到這條。
101
+ connect_core.TargetUnit('兩階段', break_detect=True, exceptions_=exceptions.TwoFactorAuthRequired()),
100
102
  connect_core.TargetUnit('任意鍵', response=' '),
101
103
  connect_core.TargetUnit('正在更新與同步線上使用者及好友名單'),
102
104
  connect_core.TargetUnit('【分類看板】', response=command.go_main_menu),
@@ -38,6 +38,16 @@ class LoginError(Error):
38
38
  return self.message
39
39
 
40
40
 
41
+ # 繼承 LoginError 以維持既有 `except LoginError` 呼叫端的相容性。
42
+ # PyPtt 不實作 TOTP 自動輸入, 這裡只負責偵測畫面並指路。
43
+ class TwoFactorAuthRequired(LoginError):
44
+ def __init__(self):
45
+ self.message = i18n.two_factor_auth_required
46
+
47
+ def __str__(self):
48
+ return self.message
49
+
50
+
41
51
  class NoFastComment(Error):
42
52
  def __init__(self):
43
53
  self.message = i18n.no_fast_comment
@@ -110,6 +110,14 @@ string_data = {
110
110
  "success": "Success",
111
111
  "title": "Title",
112
112
  "transaction_cancelled": "The transaction is cancelled!",
113
+ "two_factor_auth_required": (
114
+ "This account has two-factor authentication (2FA) enabled, and PyPtt cannot "
115
+ "complete the verification automatically. PTT's 2FA can be configured to only "
116
+ "require verification from new IPs, so logging in again from the same IP will "
117
+ "skip it. Please first manually log in to PTT from this machine using a regular "
118
+ "BBS client and complete one 2FA verification; afterwards this machine's IP will "
119
+ "be considered verified, and you can then log in with PyPtt."
120
+ ),
113
121
  "unregistered_user_cant_use_all_api": "Unregistered UserField Can't Use All API",
114
122
  "unregistered_user_cant_use_this_api": "Unregistered UserField Can't Use This API",
115
123
  "update_remote_version": "Fetching latest version",
@@ -110,6 +110,12 @@ string_data = {
110
110
  "success": "成功",
111
111
  "title": "標題",
112
112
  "transaction_cancelled": "交易取消!",
113
+ "two_factor_auth_required": (
114
+ "此帳號已啟用兩階段驗證(2FA), PyPtt 無法自動完成驗證。"
115
+ "PTT 的兩階段驗證可設定為「僅新 IP 需要驗證」, 同一 IP 再次登入時會跳過驗證。"
116
+ "請先在這台機器上使用一般 BBS 客戶端手動登入 PTT 並完成一次兩階段驗證, "
117
+ "之後這台機器的 IP 即可被視為已驗證, 再用 PyPtt 登入。"
118
+ ),
113
119
  "unregistered_user_cant_use_all_api": "未註冊使用者,將無法使用全部功能",
114
120
  "unregistered_user_cant_use_this_api": "未註冊使用者,無法使用此功能",
115
121
  "update_remote_version": "確認最新版本",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PyPtt
3
- Version: 2.3.5
3
+ Version: 2.3.6
4
4
  Summary: PyPtt github: https://github.com/PyPtt/PyPtt
5
5
  Author-email: CodingMan <pttcodingman@gmail.com>
6
6
  License: GNU Lesser General Public License v3 (LGPLv3)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes