PyPtt 1.2.14__tar.gz → 1.2.16__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 (52) hide show
  1. {pyptt-1.2.14 → pyptt-1.2.16}/PKG-INFO +12 -2
  2. {pyptt-1.2.14 → pyptt-1.2.16}/PyPtt/__init__.py +1 -1
  3. {pyptt-1.2.14 → pyptt-1.2.16}/PyPtt/_api_comment.py +22 -17
  4. {pyptt-1.2.14 → pyptt-1.2.16}/PyPtt/_api_get_post.py +1 -1
  5. {pyptt-1.2.14 → pyptt-1.2.16}/PyPtt/_api_loginout.py +6 -33
  6. pyptt-1.2.16/PyPtt/ssl_config.py +24 -0
  7. {pyptt-1.2.14 → pyptt-1.2.16}/PyPtt.egg-info/PKG-INFO +12 -2
  8. pyptt-1.2.14/PyPtt/ssl_config.py +0 -24
  9. {pyptt-1.2.14 → pyptt-1.2.16}/LICENSE +0 -0
  10. {pyptt-1.2.14 → pyptt-1.2.16}/MANIFEST.in +0 -0
  11. {pyptt-1.2.14 → pyptt-1.2.16}/PyPtt/PTT.py +0 -0
  12. {pyptt-1.2.14 → pyptt-1.2.16}/PyPtt/_api_bucket.py +0 -0
  13. {pyptt-1.2.14 → pyptt-1.2.16}/PyPtt/_api_call_status.py +0 -0
  14. {pyptt-1.2.14 → pyptt-1.2.16}/PyPtt/_api_change_pw.py +0 -0
  15. {pyptt-1.2.14 → pyptt-1.2.16}/PyPtt/_api_del_post.py +0 -0
  16. {pyptt-1.2.14 → pyptt-1.2.16}/PyPtt/_api_get_board_info.py +0 -0
  17. {pyptt-1.2.14 → pyptt-1.2.16}/PyPtt/_api_get_board_list.py +0 -0
  18. {pyptt-1.2.14 → pyptt-1.2.16}/PyPtt/_api_get_bottom_post_list.py +0 -0
  19. {pyptt-1.2.14 → pyptt-1.2.16}/PyPtt/_api_get_favourite_board.py +0 -0
  20. {pyptt-1.2.14 → pyptt-1.2.16}/PyPtt/_api_get_newest_index.py +0 -0
  21. {pyptt-1.2.14 → pyptt-1.2.16}/PyPtt/_api_get_post_index.py +0 -0
  22. {pyptt-1.2.14 → pyptt-1.2.16}/PyPtt/_api_get_time.py +0 -0
  23. {pyptt-1.2.14 → pyptt-1.2.16}/PyPtt/_api_get_user.py +0 -0
  24. {pyptt-1.2.14 → pyptt-1.2.16}/PyPtt/_api_give_money.py +0 -0
  25. {pyptt-1.2.14 → pyptt-1.2.16}/PyPtt/_api_has_new_mail.py +0 -0
  26. {pyptt-1.2.14 → pyptt-1.2.16}/PyPtt/_api_mail.py +0 -0
  27. {pyptt-1.2.14 → pyptt-1.2.16}/PyPtt/_api_mark_post.py +0 -0
  28. {pyptt-1.2.14 → pyptt-1.2.16}/PyPtt/_api_post.py +0 -0
  29. {pyptt-1.2.14 → pyptt-1.2.16}/PyPtt/_api_reply_post.py +0 -0
  30. {pyptt-1.2.14 → pyptt-1.2.16}/PyPtt/_api_search_user.py +0 -0
  31. {pyptt-1.2.14 → pyptt-1.2.16}/PyPtt/_api_set_board_title.py +0 -0
  32. {pyptt-1.2.14 → pyptt-1.2.16}/PyPtt/_api_util.py +0 -0
  33. {pyptt-1.2.14 → pyptt-1.2.16}/PyPtt/check_value.py +0 -0
  34. {pyptt-1.2.14 → pyptt-1.2.16}/PyPtt/command.py +0 -0
  35. {pyptt-1.2.14 → pyptt-1.2.16}/PyPtt/config.py +0 -0
  36. {pyptt-1.2.14 → pyptt-1.2.16}/PyPtt/connect_core.py +0 -0
  37. {pyptt-1.2.14 → pyptt-1.2.16}/PyPtt/data_type.py +0 -0
  38. {pyptt-1.2.14 → pyptt-1.2.16}/PyPtt/exceptions.py +0 -0
  39. {pyptt-1.2.14 → pyptt-1.2.16}/PyPtt/i18n.py +0 -0
  40. {pyptt-1.2.14 → pyptt-1.2.16}/PyPtt/lang_en_US.py +0 -0
  41. {pyptt-1.2.14 → pyptt-1.2.16}/PyPtt/lang_zh_TW.py +0 -0
  42. {pyptt-1.2.14 → pyptt-1.2.16}/PyPtt/lib_util.py +0 -0
  43. {pyptt-1.2.14 → pyptt-1.2.16}/PyPtt/log.py +0 -0
  44. {pyptt-1.2.14 → pyptt-1.2.16}/PyPtt/screens.py +0 -0
  45. {pyptt-1.2.14 → pyptt-1.2.16}/PyPtt/service.py +0 -0
  46. {pyptt-1.2.14 → pyptt-1.2.16}/PyPtt.egg-info/SOURCES.txt +0 -0
  47. {pyptt-1.2.14 → pyptt-1.2.16}/PyPtt.egg-info/dependency_links.txt +0 -0
  48. {pyptt-1.2.14 → pyptt-1.2.16}/PyPtt.egg-info/requires.txt +0 -0
  49. {pyptt-1.2.14 → pyptt-1.2.16}/PyPtt.egg-info/top_level.txt +0 -0
  50. {pyptt-1.2.14 → pyptt-1.2.16}/README.md +0 -0
  51. {pyptt-1.2.14 → pyptt-1.2.16}/setup.cfg +0 -0
  52. {pyptt-1.2.14 → pyptt-1.2.16}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: PyPtt
3
- Version: 1.2.14
3
+ Version: 1.2.16
4
4
  Summary: PyPtt
5
5
  Home-page: https://pyptt.cc/
6
6
  Author: CodingMan
@@ -30,6 +30,16 @@ Requires-Dist: uao
30
30
  Requires-Dist: requests
31
31
  Requires-Dist: AutoStrEnum
32
32
  Requires-Dist: PyYAML
33
+ Dynamic: author
34
+ Dynamic: author-email
35
+ Dynamic: classifier
36
+ Dynamic: description
37
+ Dynamic: description-content-type
38
+ Dynamic: home-page
39
+ Dynamic: keywords
40
+ Dynamic: requires-dist
41
+ Dynamic: requires-python
42
+ Dynamic: summary
33
43
 
34
44
  ![](https://raw.githubusercontent.com/PttCodingMan/PyPtt/master/logo/facebook_cover_photo_2.png)
35
45
  # PyPtt
@@ -1,4 +1,4 @@
1
- __version__ = '1.2.14'
1
+ __version__ = '1.2.16'
2
2
 
3
3
  from .PTT import API
4
4
  from .data_type import *
@@ -174,26 +174,31 @@ def comment(api, board: str, push_type: data_type.CommentType, push_content: str
174
174
  max_push_length = 58 - len(api.ptt_id)
175
175
 
176
176
  push_content = push_content.strip()
177
-
178
177
  push_list = []
178
+
179
179
  while push_content:
180
- index = 0
181
- jump = 0
182
-
183
- while len(push_content[:index].encode('big5uao', 'replace')) < max_push_length:
184
-
185
- if index == len(push_content):
186
- break
187
- if push_content[index] == '\n':
188
- jump = 1
180
+ # 先找出符合長度限制的最大子字串
181
+ test_content = push_content
182
+ while test_content:
183
+ if len(test_content.encode('big5uao', 'replace')) <= max_push_length:
189
184
  break
185
+ test_content = test_content[:-1]
186
+
187
+ # 找換行符號
188
+ newline_pos = test_content.find('\n')
189
+ if newline_pos != -1:
190
+ # 如果有換行,就切到換行為止
191
+ push_list.append(push_content[:newline_pos])
192
+ push_content = push_content[newline_pos + 1:]
193
+ else:
194
+ # 沒有換行就用符合長度的最大子字串
195
+ if not test_content:
196
+ # 保險起見,避免無限迴圈
197
+ test_content = push_content[:1]
198
+ push_list.append(test_content)
199
+ push_content = push_content[len(test_content):]
190
200
 
191
- index += 1
192
-
193
- push_list.append(push_content[:index])
194
- push_content = push_content[index + jump:]
195
-
196
- push_list = filter(None, push_list)
201
+ push_list = list(filter(None, push_list))
197
202
 
198
203
  for comment in push_list:
199
204
 
@@ -208,4 +213,4 @@ def comment(api, board: str, push_type: data_type.CommentType, push_content: str
208
213
  log.logger.info(i18n.wait_for_no_fast_comment)
209
214
  time.sleep(5.2)
210
215
 
211
- log.logger.info(i18n.comment, '...', i18n.success)
216
+ log.logger.info(f"{i18n.comment}...{i18n.success}")
@@ -50,7 +50,7 @@ def get_post(api, board: str, aid: Optional[str] = None, index: Optional[int] =
50
50
  if len(board) == 0:
51
51
  raise ValueError(f'board error parameter: {board}')
52
52
 
53
- if index > 0 and aid is not None:
53
+ if (index is not None and index > 0) and aid is not None:
54
54
  raise ValueError('wrong parameter index and aid can\'t both input')
55
55
 
56
56
  if aid is not None:
@@ -45,7 +45,7 @@ def logout(api) -> None:
45
45
  log.logger.info(i18n.logout, '...', i18n.success)
46
46
 
47
47
 
48
- def login(api, ptt_id: str, ptt_pw: str, kick_other_session: bool):
48
+ def login(api, ptt_id: str, ptt_pw: str, kick_other_session: bool) -> None:
49
49
  _api_util.one_thread(api)
50
50
 
51
51
  check_value.check_type(ptt_id, str, 'ptt_id')
@@ -57,34 +57,17 @@ def login(api, ptt_id: str, ptt_pw: str, kick_other_session: bool):
57
57
 
58
58
  api.config.kick_other_session = kick_other_session
59
59
 
60
- def kick_other_login_display_msg():
61
- if api.config.kick_other_session:
62
- return i18n.kick_other_login
63
- return i18n.not_kick_other_login
64
-
65
60
  def kick_other_login_response(screen):
66
- if api.config.kick_other_session:
67
- return 'y' + command.enter
68
- return 'n' + command.enter
61
+ return ('y' if api.config.kick_other_session else 'n') + command.enter
69
62
 
70
63
  api.is_mailbox_full = False
71
64
 
72
- # def is_mailbox_full():
73
- # log.log(
74
- # api.config,
75
- # LogLevel.INFO,
76
- # i18n.MailBoxFull)
77
- # api.is_mailbox_full = True
78
-
79
65
  def register_processing(screen):
80
66
  pattern = re.compile(r'[\d]+')
81
67
  api.process_picks = int(pattern.search(screen).group(0))
82
-
83
- if len(ptt_pw) > 8:
84
- ptt_pw = ptt_pw[:8]
85
-
86
- ptt_id = ptt_id.strip()
87
- ptt_pw = ptt_pw.strip()
68
+
69
+ ptt_id = ptt_id[:12].strip()
70
+ ptt_pw = ptt_pw[:8].strip()
88
71
 
89
72
  api.ptt_id = ptt_id
90
73
  api._ptt_pw = ptt_pw
@@ -108,11 +91,7 @@ def login(api, ptt_id: str, ptt_pw: str, kick_other_session: bool):
108
91
  connect_core.TargetUnit('有一篇文章尚未完成', response='Q' + command.enter),
109
92
  connect_core.TargetUnit(
110
93
  '請重新設定您的聯絡信箱', break_detect=True, exceptions_=exceptions.ResetYourContactEmail()),
111
- # connect_core.TargetUnit(
112
- # i18n.in_login_process_please_wait,
113
- # '登入中,請稍候'),
114
94
  connect_core.TargetUnit('密碼正確'),
115
- # 密碼正確
116
95
  connect_core.TargetUnit('您想刪除其他重複登入的連線嗎', response=kick_other_login_response),
117
96
  connect_core.TargetUnit('◆ 您的註冊申請單尚在處理中', response=command.enter, handler=register_processing),
118
97
  connect_core.TargetUnit('任意鍵', response=' '),
@@ -162,7 +141,6 @@ def login(api, ptt_id: str, ptt_pw: str, kick_other_session: bool):
162
141
 
163
142
  if current_capacity > max_capacity:
164
143
  api.is_mailbox_full = True
165
-
166
144
  log.logger.info(i18n.mail_box_full)
167
145
 
168
146
  if api.is_mailbox_full:
@@ -182,12 +160,7 @@ def login(api, ptt_id: str, ptt_pw: str, kick_other_session: bool):
182
160
 
183
161
  ori_screen = api.connect_core.get_screen_queue()[-1]
184
162
 
185
- is_login = True
186
-
187
- for t in screens.Target.MainMenu:
188
- if t not in ori_screen:
189
- is_login = False
190
- break
163
+ is_login = all(t in ori_screen for t in screens.Target.MainMenu)
191
164
 
192
165
  if not is_login:
193
166
  raise exceptions.LoginError()
@@ -0,0 +1,24 @@
1
+ key = """-----BEGIN EC PARAMETERS-----
2
+ BggqhkjOPQMBBw==
3
+ -----END EC PARAMETERS-----
4
+ -----BEGIN EC PRIVATE KEY-----
5
+ MHcCAQEEIFaMupPGfs4HeNqeO79cQ/T8oFhOW9XpJAOy7oc247DnoAoGCCqGSM49
6
+ AwEHoUQDQgAESBT3HZWk/z7G0RWKULAbhYW3QEu6LWz8Js3N9vWefgEJSrSlSHw+
7
+ uM06lbX+d6xXWFS0hkAYNP2IpsUyHEEFkg==
8
+ -----END EC PRIVATE KEY-----
9
+ """
10
+
11
+ cert = """-----BEGIN CERTIFICATE-----
12
+ MIIB6jCCAY8CFHEG4hrPag+DbRaGd+PG27opXSxKMAoGCCqGSM49BAMCMHcxCzAJ
13
+ BgNVBAYTAlRXMQ4wDAYDVQQIDAVTdGF0ZTENMAsGA1UEBwwEQ2l0eTEVMBMGA1UE
14
+ CgwMT3JnYW5pemF0aW9uMRwwGgYDVQQLDBNPcmdhbml6YXRpb25hbCBVbml0MRQw
15
+ EgYDVQQDDAtDb21tb24gTmFtZTAeFw0yNTAyMDMwODIyMzRaFw0zNTAyMDEwODIy
16
+ MzRaMHcxCzAJBgNVBAYTAlRXMQ4wDAYDVQQIDAVTdGF0ZTENMAsGA1UEBwwEQ2l0
17
+ eTEVMBMGA1UECgwMT3JnYW5pemF0aW9uMRwwGgYDVQQLDBNPcmdhbml6YXRpb25h
18
+ bCBVbml0MRQwEgYDVQQDDAtDb21tb24gTmFtZTBZMBMGByqGSM49AgEGCCqGSM49
19
+ AwEHA0IABEgU9x2VpP8+xtEVilCwG4WFt0BLui1s/CbNzfb1nn4BCUq0pUh8PrjN
20
+ OpW1/nesV1hUtIZAGDT9iKbFMhxBBZIwCgYIKoZIzj0EAwIDSQAwRgIhAINzsXQz
21
+ RAF1+F8ECSP3fyPH4FUw32kzoKRA5V0iR6uXAiEAwevGdpqmUIKRLGgAT/N/iZdi
22
+ RkBaBNzGzP0yguxa5rg=
23
+ -----END CERTIFICATE-----
24
+ """
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: PyPtt
3
- Version: 1.2.14
3
+ Version: 1.2.16
4
4
  Summary: PyPtt
5
5
  Home-page: https://pyptt.cc/
6
6
  Author: CodingMan
@@ -30,6 +30,16 @@ Requires-Dist: uao
30
30
  Requires-Dist: requests
31
31
  Requires-Dist: AutoStrEnum
32
32
  Requires-Dist: PyYAML
33
+ Dynamic: author
34
+ Dynamic: author-email
35
+ Dynamic: classifier
36
+ Dynamic: description
37
+ Dynamic: description-content-type
38
+ Dynamic: home-page
39
+ Dynamic: keywords
40
+ Dynamic: requires-dist
41
+ Dynamic: requires-python
42
+ Dynamic: summary
33
43
 
34
44
  ![](https://raw.githubusercontent.com/PttCodingMan/PyPtt/master/logo/facebook_cover_photo_2.png)
35
45
  # PyPtt
@@ -1,24 +0,0 @@
1
- key = """-----BEGIN EC PARAMETERS-----
2
- BggqhkjOPQMBBw==
3
- -----END EC PARAMETERS-----
4
- -----BEGIN EC PRIVATE KEY-----
5
- MHcCAQEEIHQKR027PpIL3jmuBY5pi1vyf2rPKrwD82nunY3W3TMmoAoGCCqGSM49
6
- AwEHoUQDQgAEfytUFoMyXqYe6oxI6aEnlC1Dus/7BwNUF+nIImcZfu4FsB5MABaY
7
- eAcizNFQoYjdraGBnzf5jTrq6e1RpPXp1w==
8
- -----END EC PRIVATE KEY-----
9
- """
10
-
11
- cert = """-----BEGIN CERTIFICATE-----
12
- MIIB6jCCAY8CFCxDTDYHKrP92XJ2rvne0cPov0MwMAoGCCqGSM49BAMCMHcxCzAJ
13
- BgNVBAYTAlRXMQ4wDAYDVQQIDAVTdGF0ZTENMAsGA1UEBwwEQ2l0eTEVMBMGA1UE
14
- CgwMT3JnYW5pemF0aW9uMRwwGgYDVQQLDBNPcmdhbml6YXRpb25hbCBVbml0MRQw
15
- EgYDVQQDDAtDb21tb24gTmFtZTAeFw0yNDExMTgwNjMzMDBaFw0zNDExMTYwNjMz
16
- MDBaMHcxCzAJBgNVBAYTAlRXMQ4wDAYDVQQIDAVTdGF0ZTENMAsGA1UEBwwEQ2l0
17
- eTEVMBMGA1UECgwMT3JnYW5pemF0aW9uMRwwGgYDVQQLDBNPcmdhbml6YXRpb25h
18
- bCBVbml0MRQwEgYDVQQDDAtDb21tb24gTmFtZTBZMBMGByqGSM49AgEGCCqGSM49
19
- AwEHA0IABH8rVBaDMl6mHuqMSOmhJ5QtQ7rP+wcDVBfpyCJnGX7uBbAeTAAWmHgH
20
- IszRUKGI3a2hgZ83+Y066untUaT16dcwCgYIKoZIzj0EAwIDSQAwRgIhAJVuVStG
21
- fi//wdAZFxzyRDltvFzKRbaCevD+roKvQU1cAiEAldq+ezbZqZ+PTDnDfHhWVaat
22
- L3s8iEZU0khAttFpXVo=
23
- -----END CERTIFICATE-----
24
- """
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