PyPtt 2.0.6__tar.gz → 2.0.7__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.
- {pyptt-2.0.6 → pyptt-2.0.7}/PKG-INFO +1 -1
- {pyptt-2.0.6 → pyptt-2.0.7}/PyPtt/__init__.py +1 -1
- {pyptt-2.0.6 → pyptt-2.0.7}/PyPtt/_api_get_user.py +24 -7
- {pyptt-2.0.6 → pyptt-2.0.7}/PyPtt/_api_get_waterball.py +10 -2
- {pyptt-2.0.6 → pyptt-2.0.7}/PyPtt/screens.py +2 -0
- pyptt-2.0.7/PyPtt/ssl_config.py +24 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/PyPtt.egg-info/PKG-INFO +1 -1
- pyptt-2.0.6/PyPtt/ssl_config.py +0 -24
- {pyptt-2.0.6 → pyptt-2.0.7}/LICENSE +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/PyPtt/PTT.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/PyPtt/_api_bucket.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/PyPtt/_api_call_status.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/PyPtt/_api_change_pw.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/PyPtt/_api_comment.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/PyPtt/_api_del_post.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/PyPtt/_api_get_board_info.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/PyPtt/_api_get_board_list.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/PyPtt/_api_get_bottom_post_list.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/PyPtt/_api_get_favourite_board.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/PyPtt/_api_get_newest_index.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/PyPtt/_api_get_post.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/PyPtt/_api_get_post_index.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/PyPtt/_api_get_post_list.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/PyPtt/_api_get_time.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/PyPtt/_api_give_money.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/PyPtt/_api_has_new_mail.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/PyPtt/_api_loginout.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/PyPtt/_api_mail.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/PyPtt/_api_mark_post.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/PyPtt/_api_post.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/PyPtt/_api_reply_post.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/PyPtt/_api_search_user.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/PyPtt/_api_set_board_title.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/PyPtt/_api_util.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/PyPtt/api_server.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/PyPtt/check_value.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/PyPtt/command.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/PyPtt/config.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/PyPtt/connect_core.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/PyPtt/data_type.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/PyPtt/exceptions.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/PyPtt/i18n.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/PyPtt/lang_en_US.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/PyPtt/lang_zh_TW.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/PyPtt/lib_util.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/PyPtt/log.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/PyPtt/service.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/PyPtt.egg-info/SOURCES.txt +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/PyPtt.egg-info/dependency_links.txt +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/PyPtt.egg-info/requires.txt +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/PyPtt.egg-info/top_level.txt +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/README.md +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/pyproject.toml +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/setup.cfg +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/setup.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/tests/test_change_pw.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/tests/test_comment.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/tests/test_del_post.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/tests/test_exceptions.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/tests/test_get_board_info.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/tests/test_get_board_list.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/tests/test_get_bottom_post_list.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/tests/test_get_favourite_boards.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/tests/test_get_mail.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/tests/test_get_newest_index.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/tests/test_get_post.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/tests/test_get_post_list.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/tests/test_get_post_parser.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/tests/test_get_time.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/tests/test_get_user.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/tests/test_get_waterball.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/tests/test_give_money.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/tests/test_i18n.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/tests/test_init.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/tests/test_logger.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/tests/test_parse_query_post.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/tests/test_post.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/tests/test_reply_post.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/tests/test_search_user.py +0 -0
- {pyptt-2.0.6 → pyptt-2.0.7}/tests/test_service.py +0 -0
|
@@ -76,7 +76,13 @@ def get_user(api, ptt_id: str) -> Dict:
|
|
|
76
76
|
|
|
77
77
|
# 《個人名片》CodingMan 目前沒有名片
|
|
78
78
|
|
|
79
|
-
lines = ori_screen.split('\n')
|
|
79
|
+
lines = ori_screen.split('\n')
|
|
80
|
+
|
|
81
|
+
def find_line(marker):
|
|
82
|
+
for i, line in enumerate(lines):
|
|
83
|
+
if marker in line:
|
|
84
|
+
return i, line
|
|
85
|
+
return -1, ''
|
|
80
86
|
|
|
81
87
|
def parse_user_info_from_line(line: str) -> (str, str):
|
|
82
88
|
part_0 = line[line.find('》') + 1:]
|
|
@@ -86,9 +92,20 @@ def get_user(api, ptt_id: str) -> Dict:
|
|
|
86
92
|
|
|
87
93
|
return part_0, part_1
|
|
88
94
|
|
|
89
|
-
|
|
95
|
+
id_idx, id_line = find_line('《ID暱稱》')
|
|
96
|
+
login_idx, login_line = find_line('《登入次數》')
|
|
97
|
+
activity_idx, activity_line = find_line('《目前動態》')
|
|
98
|
+
last_login_idx, last_login_line = find_line('《上次上站》')
|
|
99
|
+
chess_idx, chess_line = find_line('《 五子棋 》')
|
|
100
|
+
|
|
101
|
+
if any(idx == -1 for idx in [id_idx, login_idx, activity_idx, last_login_idx, chess_idx]):
|
|
102
|
+
log.logger.debug('get_user_parse_error', ori_screen)
|
|
103
|
+
raise exceptions.UnknownError(f'get_user parse error: {ori_screen}')
|
|
104
|
+
|
|
105
|
+
ptt_id, buff_1 = parse_user_info_from_line(id_line)
|
|
90
106
|
money = int(int_list[0]) if len(int_list := re.findall(r'\d+', buff_1)) > 0 else buff_1
|
|
91
|
-
|
|
107
|
+
|
|
108
|
+
buff_0, buff_1 = parse_user_info_from_line(login_line)
|
|
92
109
|
|
|
93
110
|
login_count = int(re.findall(r'\d+', buff_0)[0])
|
|
94
111
|
account_verified = ('同天內只計一次' in buff_0)
|
|
@@ -100,11 +117,11 @@ def get_user(api, ptt_id: str) -> Dict:
|
|
|
100
117
|
else:
|
|
101
118
|
illegal_post = None
|
|
102
119
|
|
|
103
|
-
activity, mail = parse_user_info_from_line(
|
|
104
|
-
last_login_date, last_login_ip = parse_user_info_from_line(
|
|
105
|
-
five_chess, chess = parse_user_info_from_line(
|
|
120
|
+
activity, mail = parse_user_info_from_line(activity_line)
|
|
121
|
+
last_login_date, last_login_ip = parse_user_info_from_line(last_login_line)
|
|
122
|
+
five_chess, chess = parse_user_info_from_line(chess_line)
|
|
106
123
|
|
|
107
|
-
signature_file = '\n'.join(lines[
|
|
124
|
+
signature_file = '\n'.join(lines[chess_idx + 1:-1]).strip('\n')
|
|
108
125
|
|
|
109
126
|
log.logger.debug('ptt_id', ptt_id)
|
|
110
127
|
log.logger.debug('money', money)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
import re
|
|
4
|
+
from datetime import datetime
|
|
4
5
|
from typing import List, Dict
|
|
5
6
|
|
|
6
7
|
from . import _api_util
|
|
@@ -19,6 +20,11 @@ _to_target_pattern = re.compile(r'To (\S+):')
|
|
|
19
20
|
_from_target_pattern = re.compile(r'★(\S+) ')
|
|
20
21
|
|
|
21
22
|
|
|
23
|
+
def _parse_date(date_str: str) -> datetime:
|
|
24
|
+
"""Parse waterball date string into datetime object."""
|
|
25
|
+
return datetime.strptime(date_str, '%m/%d/%Y %H:%M:%S')
|
|
26
|
+
|
|
27
|
+
|
|
22
28
|
def _merge_continuation_lines(lines: list) -> list:
|
|
23
29
|
merged = []
|
|
24
30
|
i = 0
|
|
@@ -52,7 +58,7 @@ def _parse_waterball_line(line: str) -> Dict | None:
|
|
|
52
58
|
WaterballField.type: WaterballType.SEND,
|
|
53
59
|
WaterballField.target: target,
|
|
54
60
|
WaterballField.content: content,
|
|
55
|
-
WaterballField.date: date,
|
|
61
|
+
WaterballField.date: _parse_date(date),
|
|
56
62
|
}
|
|
57
63
|
elif line.startswith('★'):
|
|
58
64
|
target_match = _from_target_pattern.search(line)
|
|
@@ -66,7 +72,7 @@ def _parse_waterball_line(line: str) -> Dict | None:
|
|
|
66
72
|
WaterballField.type: WaterballType.CATCH,
|
|
67
73
|
WaterballField.target: target,
|
|
68
74
|
WaterballField.content: content,
|
|
69
|
-
WaterballField.date: date,
|
|
75
|
+
WaterballField.date: _parse_date(date),
|
|
70
76
|
}
|
|
71
77
|
return None
|
|
72
78
|
|
|
@@ -128,6 +134,8 @@ def get_waterball(api, post_action: WaterballPostAction = WaterballPostAction.KE
|
|
|
128
134
|
target_list_exit = [
|
|
129
135
|
connect_core.TargetUnit(screens.Target.WaterBallPostAction, log_level=log.DEBUG,
|
|
130
136
|
response=action_cmd + command.enter),
|
|
137
|
+
connect_core.TargetUnit(screens.Target.WaterballCleanup, log_level=log.DEBUG,
|
|
138
|
+
response='y' + command.enter),
|
|
131
139
|
connect_core.TargetUnit(screens.Target.MainMenu, log_level=log.DEBUG, break_detect=True),
|
|
132
140
|
]
|
|
133
141
|
api.connect_core.send('q', target_list_exit)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
key = """-----BEGIN EC PARAMETERS-----
|
|
2
|
+
BggqhkjOPQMBBw==
|
|
3
|
+
-----END EC PARAMETERS-----
|
|
4
|
+
-----BEGIN EC PRIVATE KEY-----
|
|
5
|
+
MHcCAQEEIFvkfPbkl4Ke99iXWTXG1LJnhFeMFREJWW9d4I76PZmGoAoGCCqGSM49
|
|
6
|
+
AwEHoUQDQgAErWNfoKcmEmi+0tNm2CCne7MhF0+4iKZYJvtrn5kxRG73XWhoR79c
|
|
7
|
+
7tfex7gLuFn/VXiP+rgDOe4MLT1LGrtD4A==
|
|
8
|
+
-----END EC PRIVATE KEY-----
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
cert = """-----BEGIN CERTIFICATE-----
|
|
12
|
+
MIIB6TCCAY8CFFzZNObjJZqIs69GFDYbSXJqNpBIMAoGCCqGSM49BAMCMHcxCzAJ
|
|
13
|
+
BgNVBAYTAlRXMQ4wDAYDVQQIDAVTdGF0ZTENMAsGA1UEBwwEQ2l0eTEVMBMGA1UE
|
|
14
|
+
CgwMT3JnYW5pemF0aW9uMRwwGgYDVQQLDBNPcmdhbml6YXRpb25hbCBVbml0MRQw
|
|
15
|
+
EgYDVQQDDAtDb21tb24gTmFtZTAeFw0yNjA0MDMxNDM1MzRaFw0zNjAzMzExNDM1
|
|
16
|
+
MzRaMHcxCzAJBgNVBAYTAlRXMQ4wDAYDVQQIDAVTdGF0ZTENMAsGA1UEBwwEQ2l0
|
|
17
|
+
eTEVMBMGA1UECgwMT3JnYW5pemF0aW9uMRwwGgYDVQQLDBNPcmdhbml6YXRpb25h
|
|
18
|
+
bCBVbml0MRQwEgYDVQQDDAtDb21tb24gTmFtZTBZMBMGByqGSM49AgEGCCqGSM49
|
|
19
|
+
AwEHA0IABK1jX6CnJhJovtLTZtggp3uzIRdPuIimWCb7a5+ZMURu911oaEe/XO7X
|
|
20
|
+
3se4C7hZ/1V4j/q4AznuDC09Sxq7Q+AwCgYIKoZIzj0EAwIDSAAwRQIhAOAM8IPM
|
|
21
|
+
5D4BoaWYf3SaSVzrm8v6FtSIhWrSYJatYjwoAiAW3NggrC+qYY3wYRDq8UmaiHLv
|
|
22
|
+
pkJCEsbjl+remcwPbg==
|
|
23
|
+
-----END CERTIFICATE-----
|
|
24
|
+
"""
|
pyptt-2.0.6/PyPtt/ssl_config.py
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
key = """-----BEGIN EC PARAMETERS-----
|
|
2
|
-
BggqhkjOPQMBBw==
|
|
3
|
-
-----END EC PARAMETERS-----
|
|
4
|
-
-----BEGIN EC PRIVATE KEY-----
|
|
5
|
-
MHcCAQEEIFnari/tIK4DobE9n6Q66VNwZ3iIMO4OIfYlxriiiiO2oAoGCCqGSM49
|
|
6
|
-
AwEHoUQDQgAEPB+56uUrwmG6uqxqvRWA/Q3qEMYcmyw4c/KgEKLN8IpzzH8oqfrc
|
|
7
|
-
94C1WVZ6w/VBePPn8NG4EOTSEzJoMEHKkQ==
|
|
8
|
-
-----END EC PRIVATE KEY-----
|
|
9
|
-
"""
|
|
10
|
-
|
|
11
|
-
cert = """-----BEGIN CERTIFICATE-----
|
|
12
|
-
MIIB6jCCAY8CFAqMFEZkRx5MTexvhJ87UaaYKbmNMAoGCCqGSM49BAMCMHcxCzAJ
|
|
13
|
-
BgNVBAYTAlRXMQ4wDAYDVQQIDAVTdGF0ZTENMAsGA1UEBwwEQ2l0eTEVMBMGA1UE
|
|
14
|
-
CgwMT3JnYW5pemF0aW9uMRwwGgYDVQQLDBNPcmdhbml6YXRpb25hbCBVbml0MRQw
|
|
15
|
-
EgYDVQQDDAtDb21tb24gTmFtZTAeFw0yNjA0MDMwMzE5MjhaFw0zNjAzMzEwMzE5
|
|
16
|
-
MjhaMHcxCzAJBgNVBAYTAlRXMQ4wDAYDVQQIDAVTdGF0ZTENMAsGA1UEBwwEQ2l0
|
|
17
|
-
eTEVMBMGA1UECgwMT3JnYW5pemF0aW9uMRwwGgYDVQQLDBNPcmdhbml6YXRpb25h
|
|
18
|
-
bCBVbml0MRQwEgYDVQQDDAtDb21tb24gTmFtZTBZMBMGByqGSM49AgEGCCqGSM49
|
|
19
|
-
AwEHA0IABDwfuerlK8Jhurqsar0VgP0N6hDGHJssOHPyoBCizfCKc8x/KKn63PeA
|
|
20
|
-
tVlWesP1QXjz5/DRuBDk0hMyaDBBypEwCgYIKoZIzj0EAwIDSQAwRgIhAImZ1AX9
|
|
21
|
-
SW/lm0nyJMeAgtOm29LosMscrNNqoGz50Ha+AiEAxSLRceZ4WocAWxMNXXLqbRq5
|
|
22
|
-
FDyqLTDZ4WFPLAGhhkY=
|
|
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
|
|
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
|