PyPtt 2.0.4__tar.gz → 2.0.5__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 (81) hide show
  1. {pyptt-2.0.4 → pyptt-2.0.5}/PKG-INFO +1 -1
  2. {pyptt-2.0.4 → pyptt-2.0.5}/PyPtt/PTT.py +1 -4
  3. {pyptt-2.0.4 → pyptt-2.0.5}/PyPtt/__init__.py +1 -1
  4. {pyptt-2.0.4 → pyptt-2.0.5}/PyPtt/_api_get_user.py +10 -0
  5. {pyptt-2.0.4 → pyptt-2.0.5}/PyPtt/_api_util.py +10 -1
  6. pyptt-2.0.5/PyPtt/ssl_config.py +24 -0
  7. {pyptt-2.0.4 → pyptt-2.0.5}/PyPtt.egg-info/PKG-INFO +1 -1
  8. pyptt-2.0.5/tests/test_get_user.py +35 -0
  9. pyptt-2.0.4/PyPtt/ssl_config.py +0 -24
  10. pyptt-2.0.4/tests/test_get_user.py +0 -19
  11. {pyptt-2.0.4 → pyptt-2.0.5}/LICENSE +0 -0
  12. {pyptt-2.0.4 → pyptt-2.0.5}/PyPtt/_api_bucket.py +0 -0
  13. {pyptt-2.0.4 → pyptt-2.0.5}/PyPtt/_api_call_status.py +0 -0
  14. {pyptt-2.0.4 → pyptt-2.0.5}/PyPtt/_api_change_pw.py +0 -0
  15. {pyptt-2.0.4 → pyptt-2.0.5}/PyPtt/_api_comment.py +0 -0
  16. {pyptt-2.0.4 → pyptt-2.0.5}/PyPtt/_api_del_post.py +0 -0
  17. {pyptt-2.0.4 → pyptt-2.0.5}/PyPtt/_api_get_board_info.py +0 -0
  18. {pyptt-2.0.4 → pyptt-2.0.5}/PyPtt/_api_get_board_list.py +0 -0
  19. {pyptt-2.0.4 → pyptt-2.0.5}/PyPtt/_api_get_bottom_post_list.py +0 -0
  20. {pyptt-2.0.4 → pyptt-2.0.5}/PyPtt/_api_get_favourite_board.py +0 -0
  21. {pyptt-2.0.4 → pyptt-2.0.5}/PyPtt/_api_get_newest_index.py +0 -0
  22. {pyptt-2.0.4 → pyptt-2.0.5}/PyPtt/_api_get_post.py +0 -0
  23. {pyptt-2.0.4 → pyptt-2.0.5}/PyPtt/_api_get_post_index.py +0 -0
  24. {pyptt-2.0.4 → pyptt-2.0.5}/PyPtt/_api_get_post_list.py +0 -0
  25. {pyptt-2.0.4 → pyptt-2.0.5}/PyPtt/_api_get_time.py +0 -0
  26. {pyptt-2.0.4 → pyptt-2.0.5}/PyPtt/_api_get_waterball.py +0 -0
  27. {pyptt-2.0.4 → pyptt-2.0.5}/PyPtt/_api_give_money.py +0 -0
  28. {pyptt-2.0.4 → pyptt-2.0.5}/PyPtt/_api_has_new_mail.py +0 -0
  29. {pyptt-2.0.4 → pyptt-2.0.5}/PyPtt/_api_loginout.py +0 -0
  30. {pyptt-2.0.4 → pyptt-2.0.5}/PyPtt/_api_mail.py +0 -0
  31. {pyptt-2.0.4 → pyptt-2.0.5}/PyPtt/_api_mark_post.py +0 -0
  32. {pyptt-2.0.4 → pyptt-2.0.5}/PyPtt/_api_post.py +0 -0
  33. {pyptt-2.0.4 → pyptt-2.0.5}/PyPtt/_api_reply_post.py +0 -0
  34. {pyptt-2.0.4 → pyptt-2.0.5}/PyPtt/_api_search_user.py +0 -0
  35. {pyptt-2.0.4 → pyptt-2.0.5}/PyPtt/_api_set_board_title.py +0 -0
  36. {pyptt-2.0.4 → pyptt-2.0.5}/PyPtt/api_server.py +0 -0
  37. {pyptt-2.0.4 → pyptt-2.0.5}/PyPtt/check_value.py +0 -0
  38. {pyptt-2.0.4 → pyptt-2.0.5}/PyPtt/command.py +0 -0
  39. {pyptt-2.0.4 → pyptt-2.0.5}/PyPtt/config.py +0 -0
  40. {pyptt-2.0.4 → pyptt-2.0.5}/PyPtt/connect_core.py +0 -0
  41. {pyptt-2.0.4 → pyptt-2.0.5}/PyPtt/data_type.py +0 -0
  42. {pyptt-2.0.4 → pyptt-2.0.5}/PyPtt/exceptions.py +0 -0
  43. {pyptt-2.0.4 → pyptt-2.0.5}/PyPtt/i18n.py +0 -0
  44. {pyptt-2.0.4 → pyptt-2.0.5}/PyPtt/lang_en_US.py +0 -0
  45. {pyptt-2.0.4 → pyptt-2.0.5}/PyPtt/lang_zh_TW.py +0 -0
  46. {pyptt-2.0.4 → pyptt-2.0.5}/PyPtt/lib_util.py +0 -0
  47. {pyptt-2.0.4 → pyptt-2.0.5}/PyPtt/log.py +0 -0
  48. {pyptt-2.0.4 → pyptt-2.0.5}/PyPtt/screens.py +0 -0
  49. {pyptt-2.0.4 → pyptt-2.0.5}/PyPtt/service.py +0 -0
  50. {pyptt-2.0.4 → pyptt-2.0.5}/PyPtt.egg-info/SOURCES.txt +0 -0
  51. {pyptt-2.0.4 → pyptt-2.0.5}/PyPtt.egg-info/dependency_links.txt +0 -0
  52. {pyptt-2.0.4 → pyptt-2.0.5}/PyPtt.egg-info/requires.txt +0 -0
  53. {pyptt-2.0.4 → pyptt-2.0.5}/PyPtt.egg-info/top_level.txt +0 -0
  54. {pyptt-2.0.4 → pyptt-2.0.5}/README.md +0 -0
  55. {pyptt-2.0.4 → pyptt-2.0.5}/pyproject.toml +0 -0
  56. {pyptt-2.0.4 → pyptt-2.0.5}/setup.cfg +0 -0
  57. {pyptt-2.0.4 → pyptt-2.0.5}/setup.py +0 -0
  58. {pyptt-2.0.4 → pyptt-2.0.5}/tests/test_change_pw.py +0 -0
  59. {pyptt-2.0.4 → pyptt-2.0.5}/tests/test_comment.py +0 -0
  60. {pyptt-2.0.4 → pyptt-2.0.5}/tests/test_del_post.py +0 -0
  61. {pyptt-2.0.4 → pyptt-2.0.5}/tests/test_exceptions.py +0 -0
  62. {pyptt-2.0.4 → pyptt-2.0.5}/tests/test_get_board_info.py +0 -0
  63. {pyptt-2.0.4 → pyptt-2.0.5}/tests/test_get_board_list.py +0 -0
  64. {pyptt-2.0.4 → pyptt-2.0.5}/tests/test_get_bottom_post_list.py +0 -0
  65. {pyptt-2.0.4 → pyptt-2.0.5}/tests/test_get_favourite_boards.py +0 -0
  66. {pyptt-2.0.4 → pyptt-2.0.5}/tests/test_get_mail.py +0 -0
  67. {pyptt-2.0.4 → pyptt-2.0.5}/tests/test_get_newest_index.py +0 -0
  68. {pyptt-2.0.4 → pyptt-2.0.5}/tests/test_get_post.py +0 -0
  69. {pyptt-2.0.4 → pyptt-2.0.5}/tests/test_get_post_list.py +0 -0
  70. {pyptt-2.0.4 → pyptt-2.0.5}/tests/test_get_post_parser.py +0 -0
  71. {pyptt-2.0.4 → pyptt-2.0.5}/tests/test_get_time.py +0 -0
  72. {pyptt-2.0.4 → pyptt-2.0.5}/tests/test_get_waterball.py +0 -0
  73. {pyptt-2.0.4 → pyptt-2.0.5}/tests/test_give_money.py +0 -0
  74. {pyptt-2.0.4 → pyptt-2.0.5}/tests/test_i18n.py +0 -0
  75. {pyptt-2.0.4 → pyptt-2.0.5}/tests/test_init.py +0 -0
  76. {pyptt-2.0.4 → pyptt-2.0.5}/tests/test_logger.py +0 -0
  77. {pyptt-2.0.4 → pyptt-2.0.5}/tests/test_parse_query_post.py +0 -0
  78. {pyptt-2.0.4 → pyptt-2.0.5}/tests/test_post.py +0 -0
  79. {pyptt-2.0.4 → pyptt-2.0.5}/tests/test_reply_post.py +0 -0
  80. {pyptt-2.0.4 → pyptt-2.0.5}/tests/test_search_user.py +0 -0
  81. {pyptt-2.0.4 → pyptt-2.0.5}/tests/test_service.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PyPtt
3
- Version: 2.0.4
3
+ Version: 2.0.5
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)
@@ -948,10 +948,7 @@ class API:
948
948
  取得水球紀錄。
949
949
 
950
950
  Args:
951
- post_action (WaterballPostAction): 取得水球後的處理方式。
952
- - ``WaterballPostAction.KEEP``(預設):保留水球記錄。
953
- - ``WaterballPostAction.CLEAR``:清除水球記錄。
954
- - ``WaterballPostAction.MAILBOX``:存入信箱。
951
+ post_action (:ref:`waterball-post-action`): 取得水球後的處理方式,預設為 KEEP。
955
952
 
956
953
  Returns:
957
954
  List[Dict],水球紀錄清單,詳見 :ref:`waterball-field`。
@@ -1,4 +1,4 @@
1
- __version__ = '2.0.4'
1
+ __version__ = '2.0.5'
2
2
 
3
3
  from .PTT import API
4
4
  from .data_type import *
@@ -34,6 +34,16 @@ def get_user(api, ptt_id: str) -> Dict:
34
34
  cmd_list.append(command.go_main_menu)
35
35
  cmd_list.append('T')
36
36
  cmd_list.append(command.enter)
37
+
38
+ cmd = ''.join(cmd_list)
39
+
40
+ target_list = [
41
+ connect_core.TargetUnit(screens.Target.InTalk, break_detect=True),
42
+ ]
43
+
44
+ api.connect_core.send(cmd, target_list)
45
+
46
+ cmd_list = []
37
47
  cmd_list.append('Q')
38
48
  cmd_list.append(command.enter)
39
49
  cmd_list.append(ptt_id)
@@ -400,6 +400,7 @@ def goto_board(api, board: str, refresh: bool = False, end: bool = False) -> Non
400
400
  connect_core.TargetUnit('互動式動畫播放中', log_level=log.DEBUG, response=command.ctrl_c * 5),
401
401
  connect_core.TargetUnit(screens.Target.InBoard, log_level=log.DEBUG, break_detect=True),
402
402
  connect_core.TargetUnit(screens.Target.InBoardWithCursor, log_level=log.DEBUG, break_detect=True),
403
+ connect_core.TargetUnit(screens.Target.MainMenu_Exiting, log_level=log.DEBUG, break_detect=True),
403
404
  ]
404
405
 
405
406
  if refresh:
@@ -414,7 +415,15 @@ def goto_board(api, board: str, refresh: bool = False, end: bool = False) -> Non
414
415
  # 這裡可能因為發現第一次進入看板會有進版畫面,一般來說都可以在 target_list 找到對應的標的
415
416
  # 但某些看板會卡在進版動畫中,但沒有顯示任意鍵繼續或互動是動畫,所以當 index == -1 (表示找不到標的 timeout 了)
416
417
  # 可以嘗試修改 cmd_list
417
- api.connect_core.send(cmd, target_list, refresh=current_refresh)
418
+ index = api.connect_core.send(cmd, target_list, refresh=current_refresh)
419
+
420
+ # index == 4 表示偵測到 MainMenu_Exiting,代表導航到看板失敗
421
+ # 可能是暫時性的問題(閒置太久、連線狀態改變等),重試一次
422
+ if index == 4:
423
+ log.logger.debug('goto_board', board, 'failed, retrying')
424
+ index = api.connect_core.send(cmd, target_list, refresh=True)
425
+ if index == 4:
426
+ raise exceptions.NoSuchBoard(api.config, board)
418
427
 
419
428
  if end:
420
429
  cmd_list = []
@@ -0,0 +1,24 @@
1
+ key = """-----BEGIN EC PARAMETERS-----
2
+ BggqhkjOPQMBBw==
3
+ -----END EC PARAMETERS-----
4
+ -----BEGIN EC PRIVATE KEY-----
5
+ MHcCAQEEIKoC26Q5VfzkSPN5TShnQWBjUczlLrchp6TUvZz3yUvGoAoGCCqGSM49
6
+ AwEHoUQDQgAE9FSTa74Y+hPSchUFAl0c0oX631NUsDjDZ2BR5/5uZ0CHcPNPiObg
7
+ D3uXFU0vPdGIqDWIDHDf3VmshiDUD9IUgQ==
8
+ -----END EC PRIVATE KEY-----
9
+ """
10
+
11
+ cert = """-----BEGIN CERTIFICATE-----
12
+ MIIB6DCCAY8CFGo6SqurrckTpxffizxr9VUuLqI9MAoGCCqGSM49BAMCMHcxCzAJ
13
+ BgNVBAYTAlRXMQ4wDAYDVQQIDAVTdGF0ZTENMAsGA1UEBwwEQ2l0eTEVMBMGA1UE
14
+ CgwMT3JnYW5pemF0aW9uMRwwGgYDVQQLDBNPcmdhbml6YXRpb25hbCBVbml0MRQw
15
+ EgYDVQQDDAtDb21tb24gTmFtZTAeFw0yNjA0MDIxNTExNTdaFw0zNjAzMzAxNTEx
16
+ NTdaMHcxCzAJBgNVBAYTAlRXMQ4wDAYDVQQIDAVTdGF0ZTENMAsGA1UEBwwEQ2l0
17
+ eTEVMBMGA1UECgwMT3JnYW5pemF0aW9uMRwwGgYDVQQLDBNPcmdhbml6YXRpb25h
18
+ bCBVbml0MRQwEgYDVQQDDAtDb21tb24gTmFtZTBZMBMGByqGSM49AgEGCCqGSM49
19
+ AwEHA0IABPRUk2u+GPoT0nIVBQJdHNKF+t9TVLA4w2dgUef+bmdAh3DzT4jm4A97
20
+ lxVNLz3RiKg1iAxw391ZrIYg1A/SFIEwCgYIKoZIzj0EAwIDRwAwRAIgSrQ9dTQ9
21
+ qajw32Ws/Ua9s3WvPaPa9QGwmv2Mm1Wk02sCICh8iO5eApwSnSD+PdoTVgrINx72
22
+ aDsfqjLNJ4BPjSDw
23
+ -----END CERTIFICATE-----
24
+ """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PyPtt
3
- Version: 2.0.4
3
+ Version: 2.0.5
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)
@@ -0,0 +1,35 @@
1
+ def _check_user_info(user_info, test_user):
2
+ assert user_info is not None, f'get_user returned None for user {test_user}'
3
+ assert 'ptt_id' in user_info
4
+ assert user_info['ptt_id'].lower().startswith(test_user.lower())
5
+ assert 'money' in user_info
6
+ assert 'login_count' in user_info
7
+ assert 'account_verified' in user_info
8
+ assert 'legal_post' in user_info
9
+ assert 'activity' in user_info
10
+ assert 'last_login_date' in user_info
11
+
12
+
13
+ def test_get_user(ptt_bots):
14
+ """Tests getting user information from PTT."""
15
+ test_users = [
16
+ 'CodingMan',
17
+ ]
18
+
19
+ for ptt_bot in ptt_bots:
20
+ for test_user in test_users:
21
+ user_info = ptt_bot.get_user(test_user)
22
+ _check_user_info(user_info, test_user)
23
+
24
+
25
+ def test_get_user_ptt1_only(ptt_bots):
26
+ """Tests getting user information that only exists on PTT1."""
27
+ ptt1_bot = ptt_bots[0]
28
+
29
+ test_users = [
30
+ 'janice001',
31
+ ]
32
+
33
+ for test_user in test_users:
34
+ user_info = ptt1_bot.get_user(test_user)
35
+ _check_user_info(user_info, test_user)
@@ -1,24 +0,0 @@
1
- key = """-----BEGIN EC PARAMETERS-----
2
- BggqhkjOPQMBBw==
3
- -----END EC PARAMETERS-----
4
- -----BEGIN EC PRIVATE KEY-----
5
- MHcCAQEEIOE3tIbWxbdarjPa0fenJkhDse+yNGE+XbNMPwJbfFOtoAoGCCqGSM49
6
- AwEHoUQDQgAErjEPTt8Rikqr4wLdGYIXhd7wS7AWvPhrt8qtDONlCjsqAQ2oY4O7
7
- G87Ah+iXl2oRF2uPzQGtfM7CFsNTlLTfbw==
8
- -----END EC PRIVATE KEY-----
9
- """
10
-
11
- cert = """-----BEGIN CERTIFICATE-----
12
- MIIB6TCCAY8CFFdRgQKRIcIm+scYtVi+9MfhfKC5MAoGCCqGSM49BAMCMHcxCzAJ
13
- BgNVBAYTAlRXMQ4wDAYDVQQIDAVTdGF0ZTENMAsGA1UEBwwEQ2l0eTEVMBMGA1UE
14
- CgwMT3JnYW5pemF0aW9uMRwwGgYDVQQLDBNPcmdhbml6YXRpb25hbCBVbml0MRQw
15
- EgYDVQQDDAtDb21tb24gTmFtZTAeFw0yNjA0MDIxMzEyMTlaFw0zNjAzMzAxMzEy
16
- MTlaMHcxCzAJBgNVBAYTAlRXMQ4wDAYDVQQIDAVTdGF0ZTENMAsGA1UEBwwEQ2l0
17
- eTEVMBMGA1UECgwMT3JnYW5pemF0aW9uMRwwGgYDVQQLDBNPcmdhbml6YXRpb25h
18
- bCBVbml0MRQwEgYDVQQDDAtDb21tb24gTmFtZTBZMBMGByqGSM49AgEGCCqGSM49
19
- AwEHA0IABK4xD07fEYpKq+MC3RmCF4Xe8EuwFrz4a7fKrQzjZQo7KgENqGODuxvO
20
- wIfol5dqERdrj80BrXzOwhbDU5S0328wCgYIKoZIzj0EAwIDSAAwRQIgO66bdeL+
21
- VmionJ9Ou8P/EOLAwVYEmopd9gMwk9NLi+8CIQDbwtIOEiojbDkOgkvdNT0YCjxh
22
- sdPJMimQlJB/o2AwBg==
23
- -----END CERTIFICATE-----
24
- """
@@ -1,19 +0,0 @@
1
- def test_get_user(ptt_bots):
2
- """Tests getting user information from PTT."""
3
- test_users = [
4
- 'CodingMan'
5
- ]
6
-
7
- for ptt_bot in ptt_bots:
8
- for test_user in test_users:
9
- user_info = ptt_bot.get_user(test_user)
10
-
11
- assert user_info is not None, f'get_user returned None for user {test_user} on host {ptt_bot.host}'
12
- assert 'ptt_id' in user_info
13
- assert user_info['ptt_id'].lower().startswith(test_user.lower())
14
- assert 'money' in user_info
15
- assert 'login_count' in user_info
16
- assert 'account_verified' in user_info
17
- assert 'legal_post' in user_info
18
- assert 'activity' in user_info
19
- assert 'last_login_date' in user_info
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