fbchat-v2 2.3.3__tar.gz → 2.3.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.
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/.gitignore +15 -1
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/CHANGELOG.md +58 -0
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/PKG-INFO +21 -12
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/README.md +19 -10
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/README_EN.md +20 -10
- fbchat_v2-2.3.5/hatch_build.py +40 -0
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/pyproject.toml +10 -2
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/__init__.py +4 -1
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/_core/README.md +1 -1
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/_core/README_EN.md +1 -1
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/_core/__init__.py +1 -1
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/_core/_facebookLogin.py +13 -3
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/_features/README.md +2 -2
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/_features/README_EN.md +2 -2
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/_features/_facebook/README.md +1 -1
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/_features/_facebook/README_EN.md +1 -1
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/_messaging/README.md +11 -3
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/_messaging/README_EN.md +12 -3
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/_messaging/__init__.py +1 -0
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/_messaging/_attachments.py +9 -8
- fbchat_v2-2.3.5/src/fbchat_v2/_messaging/_bridge_checksums.py +11 -0
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/_messaging/_listening.py +257 -39
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/_messaging/_listening_e2ee.py +749 -71
- fbchat_v2-2.3.5/src/fbchat_v2/_messaging/_reconnect.py +327 -0
- fbchat_v2-2.3.3/src/fbchat_v2/_messaging/_bridge_checksums.py +0 -11
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/LICENSE +0 -0
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/_core/_console.py +0 -0
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/_core/_http.py +0 -0
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/_core/_permissions.py +0 -0
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/_core/_session.py +0 -0
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/_core/_storage.py +0 -0
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/_core/_types.py +0 -0
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/_core/_utils.py +0 -0
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/_features/__init__.py +0 -0
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/_features/_facebook/__init__.py +0 -0
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/_features/_facebook/_archivePost.py +0 -0
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/_features/_facebook/_blocking.py +0 -0
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/_features/_facebook/_changeBio.py +0 -0
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/_features/_facebook/_createPost.py +0 -0
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/_features/_facebook/_deletePost.py +0 -0
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/_features/_facebook/_get_user_info.py +0 -0
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/_features/_facebook/_marketplace.py +0 -0
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/_features/_facebook/_notification.py +0 -0
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/_features/_facebook/_professional.py +0 -0
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/_features/_facebook/_reactionPost.py +0 -0
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/_features/_facebook/_registerOnProfile.py +0 -0
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/_features/_facebook/_search.py +0 -0
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/_features/_facebook/_unFriend.py +0 -0
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/_features/_thread/__init__.py +0 -0
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/_features/_thread/_addAdmin.py +0 -0
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/_features/_thread/_all_thread_data.py +0 -0
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/_features/_thread/_changeEmoji.py +0 -0
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/_features/_thread/_changeNameThread.py +0 -0
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/_features/_thread/_changeNickname.py +0 -0
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/_messaging/_bridge_actions.py +0 -0
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/_messaging/_changeTheme.py +0 -0
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/_messaging/_createNotes.py +0 -0
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/_messaging/_editMessage.py +0 -0
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/_messaging/_message_requests.py +0 -0
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/_messaging/_reactions.py +0 -0
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/_messaging/_send.py +0 -0
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/_messaging/_send_e2ee.py +0 -0
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/_messaging/_unsend.py +0 -0
- {fbchat_v2-2.3.3 → fbchat_v2-2.3.5}/src/fbchat_v2/py.typed +0 -0
|
@@ -38,9 +38,22 @@ venv.bak/
|
|
|
38
38
|
.settings/
|
|
39
39
|
.docs/
|
|
40
40
|
|
|
41
|
+
.vs/
|
|
42
|
+
.pytest_cache/
|
|
43
|
+
.mypy_cache/
|
|
44
|
+
.ruff_cache/
|
|
45
|
+
.hypothesis/
|
|
46
|
+
.tox/
|
|
47
|
+
.nox/
|
|
48
|
+
.venv*/
|
|
49
|
+
.coverage
|
|
50
|
+
.coverage.*
|
|
51
|
+
htmlcov/
|
|
52
|
+
coverage.xml
|
|
41
53
|
*.log
|
|
42
54
|
logs/
|
|
43
55
|
.tmp/
|
|
56
|
+
/.state/
|
|
44
57
|
*.sqlite3
|
|
45
58
|
*.db
|
|
46
59
|
*.db-journal
|
|
@@ -49,4 +62,5 @@ AGENT_MEMORYs.md
|
|
|
49
62
|
.vbsec-tmp/
|
|
50
63
|
vbsec-reports/
|
|
51
64
|
src/test.py
|
|
52
|
-
.understand-anything
|
|
65
|
+
.understand-anything
|
|
66
|
+
AGENTS_MEMORYs.md
|
|
@@ -43,6 +43,64 @@ phiên bản tuân theo [Semantic Versioning](https://semver.org/lang/vi/).
|
|
|
43
43
|
khoảng trắng thừa đầu hero, CSS variable thiếu, V2 badge bị ẩn và layout
|
|
44
44
|
contributor/preloader trên màn hình nhỏ.
|
|
45
45
|
|
|
46
|
+
## [2.3.5] - 2026-11-18
|
|
47
|
+
|
|
48
|
+
### Added
|
|
49
|
+
|
|
50
|
+
- Thêm ba ví dụ tăng dần độ khó trong `examples/`: echo, quản lý nhóm với
|
|
51
|
+
poll bằng tin nhắn và E2EE có Go bridge.
|
|
52
|
+
|
|
53
|
+
### Changed
|
|
54
|
+
|
|
55
|
+
- Chia DOCS.md thành năm trang theo tác vụ trong `docs/`, cập nhật link Việt/Anh.
|
|
56
|
+
- Refactor bot mẫu `src/main.py` và suy luận loại attachment bằng mapping,
|
|
57
|
+
giữ nguyên thứ tự ưu tiên và fallback MIME.
|
|
58
|
+
- Sinh namespace package vào `build/fbchat_v2` khi cài/build, bỏ source trùng
|
|
59
|
+
khỏi main; public imports và layout wheel không đổi.
|
|
60
|
+
- Nâng Go lên 1.26.11, brotli 1.2.7, compress 1.20.2 và x/net 0.62.0 để vá
|
|
61
|
+
các lỗ hổng dependency được CI phát hiện.
|
|
62
|
+
|
|
63
|
+
### Fixed
|
|
64
|
+
|
|
65
|
+
- Sửa fixture TOTP quá ngắn bị PyOTP 2.12 từ chối; giữ fallback 2FA hiện có.
|
|
66
|
+
- Bỏ cache IDE khỏi Git và bổ sung rule ignore cho cache công cụ phát triển.
|
|
67
|
+
|
|
68
|
+
## [2.3.4] - 2026-10-21
|
|
69
|
+
|
|
70
|
+
### Added
|
|
71
|
+
|
|
72
|
+
- Thêm `ReconnectPolicy` cho MQTT/E2EE: retry khi startup mất mạng hoặc kết nối
|
|
73
|
+
bị ngắt, exponential backoff có jitter, delay trần và retry budget tùy chọn.
|
|
74
|
+
- Thêm `connection_state`, `connection_status` và callback trạng thái. Bridge
|
|
75
|
+
cung cấp capability `structuredConnectionStatus` cùng failure code an toàn,
|
|
76
|
+
không đưa cookie, ID hội thoại hoặc nội dung chat vào snapshot.
|
|
77
|
+
- Thêm test offline cho outage, startup retry, mất riêng socket E2EE, giới hạn
|
|
78
|
+
retry, stop/cancel và lọc message replay qua các generation của bridge.
|
|
79
|
+
|
|
80
|
+
### Changed
|
|
81
|
+
|
|
82
|
+
- MQTT dùng một supervisor quản lý retry; giữ sync token/sequence và cache ID
|
|
83
|
+
có giới hạn qua reconnect. E2EE ưu tiên socket Go tự nối lại khi RPC còn khỏe,
|
|
84
|
+
chỉ thay process khi generation không thể dùng tiếp.
|
|
85
|
+
- Lỗi auth/checkpoint/config/protocol hoặc chưa phân loại được dừng rõ ràng,
|
|
86
|
+
không retry vô hạn. Lỗi chứng chỉ TLS được phân loại trước lỗi mạng chung.
|
|
87
|
+
- E2EE memory-only báo `device_state_lost` khi process chết, không tự pair mới
|
|
88
|
+
hoặc ghi key ra đĩa. Persistent device vẫn là lựa chọn chủ động của ứng dụng.
|
|
89
|
+
- Bot mẫu tiếp tục chờ khi startup đang reconnecting. Stop/cancel chờ worker
|
|
90
|
+
thu dọn, kể cả khi coroutine bị cancel nhiều lần.
|
|
91
|
+
- Nâng Go lên `1.26.10` để vá `GO-2026-6809` trong `crypto/x509`; giữ nguyên
|
|
92
|
+
vulnerability gate của CI.
|
|
93
|
+
|
|
94
|
+
### Giới hạn
|
|
95
|
+
|
|
96
|
+
- Policy của wrapper không ghi đè backoff socket native Go. Với E2EE, retry
|
|
97
|
+
budget khi native reconnect đếm lượt quan sát, không phải số TCP attempt.
|
|
98
|
+
- Reconnect không đảm bảo nhận đủ mọi tin trong thời gian offline. Khi thay
|
|
99
|
+
process, listener báo nguy cơ message gap; tin gửi có kết quả `unknown`
|
|
100
|
+
không được tự gửi lại.
|
|
101
|
+
- Các thay đổi reconnect được kiểm bằng test offline. Cold restart sau payload
|
|
102
|
+
thật và mất mạng riêng bridge vẫn cần kiểm chứng live riêng.
|
|
103
|
+
|
|
46
104
|
## [2.3.3] - 2026-10-16
|
|
47
105
|
|
|
48
106
|
### Added
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: fbchat-v2
|
|
3
|
-
Version: 2.3.
|
|
3
|
+
Version: 2.3.5
|
|
4
4
|
Summary: Async-first, account-based Python library for the unofficial Facebook Messenger API with E2EE support.
|
|
5
5
|
Project-URL: Homepage, https://github.com/m008v/fbchat-v2
|
|
6
|
-
Project-URL: Documentation, https://github.com/m008v/fbchat-v2/blob/main/
|
|
6
|
+
Project-URL: Documentation, https://github.com/m008v/fbchat-v2/blob/main/docs/getting-started/quickstart.md
|
|
7
7
|
Project-URL: Repository, https://github.com/m008v/fbchat-v2
|
|
8
8
|
Project-URL: Issues, https://github.com/m008v/fbchat-v2/issues
|
|
9
9
|
Project-URL: Changelog, https://github.com/m008v/fbchat-v2/blob/main/CHANGELOG.md
|
|
@@ -252,19 +252,19 @@ Description-Content-Type: text/markdown
|
|
|
252
252
|
[](https://github.com/m008v/fbchat-v2)
|
|
253
253
|
[](https://pypi.org/project/fbchat-v2/)
|
|
254
254
|
[](https://www.python.org/)
|
|
255
|
-
[](https://github.com/m008v/fbchat-v2/releases)
|
|
256
256
|
[](https://github.com/m008v/fbchat-v2/issues)
|
|
257
257
|
[](LICENSE)
|
|
258
258
|
[](https://t.me/MinhHuyDev)
|
|
259
259
|
|
|
260
|
-
[🇬🇧 English](README_EN.md) · [📖 Tài liệu](
|
|
260
|
+
[🇬🇧 English](README_EN.md) · [📖 Tài liệu](https://github.com/m008v/fbchat-v2/blob/main/docs/getting-started/quickstart.md) · [📦 PyPI](https://pypi.org/project/fbchat-v2/) · [ 📊 Sơ đồ luồng](FLOWCHART.md) · [🐛 Báo lỗi](https://github.com/m008v/fbchat-v2/issues)
|
|
261
261
|
|
|
262
262
|
</div>
|
|
263
263
|
|
|
264
264
|
---
|
|
265
265
|
|
|
266
266
|
> [!IMPORTANT]
|
|
267
|
-
> Bản 2.3.
|
|
267
|
+
> Bản 2.3.5 dùng `async/await`. Nếu đang dùng bản cũ, bạn cần sửa cách gọi hàm theo ví dụ bên dưới. Muốn giữ code đồng bộ thì dùng bản [v2.1.4](https://github.com/m008v/fbchat-v2/tree/v2.1.4).
|
|
268
268
|
|
|
269
269
|
> [!WARNING]
|
|
270
270
|
> Đây không phải sản phẩm chính thức của Facebook. Nếu cần API chatbot chính thức, xem [Messenger Platform](https://developers.facebook.com/docs/messenger-platform/). `fbchat-v2` dùng tài khoản và cookie Facebook cá nhân, nên có rủi ro với bảo mật phiên và tài khoản. Cân nhắc trước khi sử dụng.
|
|
@@ -276,6 +276,10 @@ Mình là MinhHuyDev (`m008v`), tác giả và người duy trì dự án.
|
|
|
276
276
|
|
|
277
277
|
`fbchat-v2` là thư viện Python để gửi và nhận tin nhắn Messenger bằng tài khoản Facebook cá nhân. Thư viện dùng `async/await`; E2EE chạy qua bridge Go. Codebase đã được tổ chức lại từ v2.2.0 và tiếp tục được sửa theo các lỗi người dùng báo về.
|
|
278
278
|
|
|
279
|
+
Từ 2.3.4, MQTT/E2EE tự nối lại khi mất mạng, phân biệt lỗi cookie và có callback
|
|
280
|
+
trạng thái. Xem [cách cấu hình](https://github.com/m008v/fbchat-v2/blob/main/docs/messaging/e2ee.md#tự-nối-lại).
|
|
281
|
+
E2EE cần bridge 2.3.5; wrapper không dùng binary cũ thiếu contract reconnect.
|
|
282
|
+
|
|
279
283
|
Cảm ơn mọi người đã góp ý và báo lỗi. Đây là API không chính thức nên một số chức năng có thể hỏng khi Facebook thay đổi. Nếu gặp lỗi, mở issue trên [GitHub](https://github.com/m008v/fbchat-v2/issues) kèm cách tái hiện và log đã che thông tin nhạy cảm, hoặc nhắn mình qua [Telegram](https://t.me/MinhHuyDev).
|
|
280
284
|
|
|
281
285
|
---
|
|
@@ -408,7 +412,7 @@ fbchat-v2/
|
|
|
408
412
|
│ └── README.md
|
|
409
413
|
├── build/ # Binary bridge local
|
|
410
414
|
├── tests/ # Unit và async contract tests
|
|
411
|
-
├──
|
|
415
|
+
├── docs/ # Hướng dẫn API đầy đủ
|
|
412
416
|
├── FLOWCHART.md # Runtime flow
|
|
413
417
|
├── mindmap-mermaid.md # Bản đồ codebase
|
|
414
418
|
├── CHANGELOG.md
|
|
@@ -422,7 +426,7 @@ fbchat-v2/
|
|
|
422
426
|
| Thành phần | Tối thiểu | Khuyến nghị | Ghi chú |
|
|
423
427
|
|---|---|---|---|
|
|
424
428
|
| Python | 3.10 | 3.11 / 3.12 | Bắt buộc |
|
|
425
|
-
| Go (toolchain) | 1.26.
|
|
429
|
+
| Go (toolchain) | 1.26.10 | 1.26.10+ | **Chỉ cần cho E2EE** - để build `fbchat-bridge-e2ee` |
|
|
426
430
|
| Git | bất kỳ | latest | Cần cho `go mod tidy` kéo `mautrix/meta` |
|
|
427
431
|
| Hệ điều hành | Windows / Linux / macOS | - | - |
|
|
428
432
|
| RAM | 256 MB | 1 GB+ | Bridge E2EE chiếm ~80–150 MB khi chạy |
|
|
@@ -501,7 +505,7 @@ Nếu chỉ dùng API HTTP hoặc listener MQTT thường, bạn có thể bỏ
|
|
|
501
505
|
|
|
502
506
|
#### 5.1. Cài Go toolchain
|
|
503
507
|
|
|
504
|
-
- Tải về: <https://go.dev/dl/> (Go ≥ 1.26.
|
|
508
|
+
- Tải về: <https://go.dev/dl/> (Go ≥ 1.26.10).
|
|
505
509
|
- Sau khi cài, mở terminal mới và kiểm tra:
|
|
506
510
|
|
|
507
511
|
```bash
|
|
@@ -545,9 +549,9 @@ Lần build đầu mất vài phút (~300 MB cache Go module). Sau đó binary k
|
|
|
545
549
|
```bash
|
|
546
550
|
cd ..
|
|
547
551
|
# Windows
|
|
548
|
-
python scripts/smoke_bridge_rpc.py .\build\fbchat-bridge-e2ee.exe --expected-version 2.3.
|
|
552
|
+
python scripts/smoke_bridge_rpc.py .\build\fbchat-bridge-e2ee.exe --expected-version 2.3.5
|
|
549
553
|
# Linux/macOS
|
|
550
|
-
python scripts/smoke_bridge_rpc.py ./build/fbchat-bridge-e2ee --expected-version 2.3.
|
|
554
|
+
python scripts/smoke_bridge_rpc.py ./build/fbchat-bridge-e2ee --expected-version 2.3.5
|
|
551
555
|
```
|
|
552
556
|
|
|
553
557
|
Nếu binary không nằm ở vị trí mặc định, đặt biến môi trường:
|
|
@@ -825,7 +829,12 @@ Queue của bot chứa tối đa 1000 event và bỏ event cũ nhất khi đầy
|
|
|
825
829
|
|
|
826
830
|
| Tài liệu | Nội dung |
|
|
827
831
|
|---|---|
|
|
828
|
-
| [
|
|
832
|
+
| [Bắt đầu](https://github.com/m008v/fbchat-v2/blob/main/docs/getting-started/quickstart.md) | Cài đặt, tạo session và chạy bot mẫu |
|
|
833
|
+
| [Ví dụ tăng dần độ khó](https://github.com/m008v/fbchat-v2/blob/main/examples/README.md) | Echo cơ bản, quản lý nhóm và E2EE |
|
|
834
|
+
| [Tin nhắn thường](https://github.com/m008v/fbchat-v2/blob/main/docs/messaging/standard.md) | Gửi/nhận, attachment, reaction và Notes |
|
|
835
|
+
| [E2EE](https://github.com/m008v/fbchat-v2/blob/main/docs/messaging/e2ee.md) | Bridge, readiness, reconnect và kiểm thử |
|
|
836
|
+
| [Thao tác Facebook](https://github.com/m008v/fbchat-v2/blob/main/docs/features/facebook-actions.md) | Bài viết, user và quản lý nhóm |
|
|
837
|
+
| [Tra nhanh](https://github.com/m008v/fbchat-v2/blob/main/docs/recipes/cheatsheet.md) | Timeout, migration và cách xử lý lỗi |
|
|
829
838
|
| [Core](src/fbchat_v2/_core/README.md) | Session, HTTP, storage và login |
|
|
830
839
|
| [Features](src/fbchat_v2/_features/README.md) | Facebook feature và thread |
|
|
831
840
|
| [Messaging](src/fbchat_v2/_messaging/README.md) | Send, listener, attachment và E2EE |
|
|
@@ -851,7 +860,7 @@ ruff check src tests scripts
|
|
|
851
860
|
black --check src tests scripts
|
|
852
861
|
mypy
|
|
853
862
|
python -m build --wheel
|
|
854
|
-
python scripts/verify_distribution.py dist/fbchat_v2-2.3.
|
|
863
|
+
python scripts/verify_distribution.py dist/fbchat_v2-2.3.5-py3-none-any.whl
|
|
855
864
|
git diff --check
|
|
856
865
|
```
|
|
857
866
|
|
|
@@ -7,19 +7,19 @@
|
|
|
7
7
|
[](https://github.com/m008v/fbchat-v2)
|
|
8
8
|
[](https://pypi.org/project/fbchat-v2/)
|
|
9
9
|
[](https://www.python.org/)
|
|
10
|
-
[](https://github.com/m008v/fbchat-v2/releases)
|
|
11
11
|
[](https://github.com/m008v/fbchat-v2/issues)
|
|
12
12
|
[](LICENSE)
|
|
13
13
|
[](https://t.me/MinhHuyDev)
|
|
14
14
|
|
|
15
|
-
[🇬🇧 English](README_EN.md) · [📖 Tài liệu](
|
|
15
|
+
[🇬🇧 English](README_EN.md) · [📖 Tài liệu](https://github.com/m008v/fbchat-v2/blob/main/docs/getting-started/quickstart.md) · [📦 PyPI](https://pypi.org/project/fbchat-v2/) · [ 📊 Sơ đồ luồng](FLOWCHART.md) · [🐛 Báo lỗi](https://github.com/m008v/fbchat-v2/issues)
|
|
16
16
|
|
|
17
17
|
</div>
|
|
18
18
|
|
|
19
19
|
---
|
|
20
20
|
|
|
21
21
|
> [!IMPORTANT]
|
|
22
|
-
> Bản 2.3.
|
|
22
|
+
> Bản 2.3.5 dùng `async/await`. Nếu đang dùng bản cũ, bạn cần sửa cách gọi hàm theo ví dụ bên dưới. Muốn giữ code đồng bộ thì dùng bản [v2.1.4](https://github.com/m008v/fbchat-v2/tree/v2.1.4).
|
|
23
23
|
|
|
24
24
|
> [!WARNING]
|
|
25
25
|
> Đây không phải sản phẩm chính thức của Facebook. Nếu cần API chatbot chính thức, xem [Messenger Platform](https://developers.facebook.com/docs/messenger-platform/). `fbchat-v2` dùng tài khoản và cookie Facebook cá nhân, nên có rủi ro với bảo mật phiên và tài khoản. Cân nhắc trước khi sử dụng.
|
|
@@ -31,6 +31,10 @@ Mình là MinhHuyDev (`m008v`), tác giả và người duy trì dự án.
|
|
|
31
31
|
|
|
32
32
|
`fbchat-v2` là thư viện Python để gửi và nhận tin nhắn Messenger bằng tài khoản Facebook cá nhân. Thư viện dùng `async/await`; E2EE chạy qua bridge Go. Codebase đã được tổ chức lại từ v2.2.0 và tiếp tục được sửa theo các lỗi người dùng báo về.
|
|
33
33
|
|
|
34
|
+
Từ 2.3.4, MQTT/E2EE tự nối lại khi mất mạng, phân biệt lỗi cookie và có callback
|
|
35
|
+
trạng thái. Xem [cách cấu hình](https://github.com/m008v/fbchat-v2/blob/main/docs/messaging/e2ee.md#tự-nối-lại).
|
|
36
|
+
E2EE cần bridge 2.3.5; wrapper không dùng binary cũ thiếu contract reconnect.
|
|
37
|
+
|
|
34
38
|
Cảm ơn mọi người đã góp ý và báo lỗi. Đây là API không chính thức nên một số chức năng có thể hỏng khi Facebook thay đổi. Nếu gặp lỗi, mở issue trên [GitHub](https://github.com/m008v/fbchat-v2/issues) kèm cách tái hiện và log đã che thông tin nhạy cảm, hoặc nhắn mình qua [Telegram](https://t.me/MinhHuyDev).
|
|
35
39
|
|
|
36
40
|
---
|
|
@@ -163,7 +167,7 @@ fbchat-v2/
|
|
|
163
167
|
│ └── README.md
|
|
164
168
|
├── build/ # Binary bridge local
|
|
165
169
|
├── tests/ # Unit và async contract tests
|
|
166
|
-
├──
|
|
170
|
+
├── docs/ # Hướng dẫn API đầy đủ
|
|
167
171
|
├── FLOWCHART.md # Runtime flow
|
|
168
172
|
├── mindmap-mermaid.md # Bản đồ codebase
|
|
169
173
|
├── CHANGELOG.md
|
|
@@ -177,7 +181,7 @@ fbchat-v2/
|
|
|
177
181
|
| Thành phần | Tối thiểu | Khuyến nghị | Ghi chú |
|
|
178
182
|
|---|---|---|---|
|
|
179
183
|
| Python | 3.10 | 3.11 / 3.12 | Bắt buộc |
|
|
180
|
-
| Go (toolchain) | 1.26.
|
|
184
|
+
| Go (toolchain) | 1.26.10 | 1.26.10+ | **Chỉ cần cho E2EE** - để build `fbchat-bridge-e2ee` |
|
|
181
185
|
| Git | bất kỳ | latest | Cần cho `go mod tidy` kéo `mautrix/meta` |
|
|
182
186
|
| Hệ điều hành | Windows / Linux / macOS | - | - |
|
|
183
187
|
| RAM | 256 MB | 1 GB+ | Bridge E2EE chiếm ~80–150 MB khi chạy |
|
|
@@ -256,7 +260,7 @@ Nếu chỉ dùng API HTTP hoặc listener MQTT thường, bạn có thể bỏ
|
|
|
256
260
|
|
|
257
261
|
#### 5.1. Cài Go toolchain
|
|
258
262
|
|
|
259
|
-
- Tải về: <https://go.dev/dl/> (Go ≥ 1.26.
|
|
263
|
+
- Tải về: <https://go.dev/dl/> (Go ≥ 1.26.10).
|
|
260
264
|
- Sau khi cài, mở terminal mới và kiểm tra:
|
|
261
265
|
|
|
262
266
|
```bash
|
|
@@ -300,9 +304,9 @@ Lần build đầu mất vài phút (~300 MB cache Go module). Sau đó binary k
|
|
|
300
304
|
```bash
|
|
301
305
|
cd ..
|
|
302
306
|
# Windows
|
|
303
|
-
python scripts/smoke_bridge_rpc.py .\build\fbchat-bridge-e2ee.exe --expected-version 2.3.
|
|
307
|
+
python scripts/smoke_bridge_rpc.py .\build\fbchat-bridge-e2ee.exe --expected-version 2.3.5
|
|
304
308
|
# Linux/macOS
|
|
305
|
-
python scripts/smoke_bridge_rpc.py ./build/fbchat-bridge-e2ee --expected-version 2.3.
|
|
309
|
+
python scripts/smoke_bridge_rpc.py ./build/fbchat-bridge-e2ee --expected-version 2.3.5
|
|
306
310
|
```
|
|
307
311
|
|
|
308
312
|
Nếu binary không nằm ở vị trí mặc định, đặt biến môi trường:
|
|
@@ -580,7 +584,12 @@ Queue của bot chứa tối đa 1000 event và bỏ event cũ nhất khi đầy
|
|
|
580
584
|
|
|
581
585
|
| Tài liệu | Nội dung |
|
|
582
586
|
|---|---|
|
|
583
|
-
| [
|
|
587
|
+
| [Bắt đầu](https://github.com/m008v/fbchat-v2/blob/main/docs/getting-started/quickstart.md) | Cài đặt, tạo session và chạy bot mẫu |
|
|
588
|
+
| [Ví dụ tăng dần độ khó](https://github.com/m008v/fbchat-v2/blob/main/examples/README.md) | Echo cơ bản, quản lý nhóm và E2EE |
|
|
589
|
+
| [Tin nhắn thường](https://github.com/m008v/fbchat-v2/blob/main/docs/messaging/standard.md) | Gửi/nhận, attachment, reaction và Notes |
|
|
590
|
+
| [E2EE](https://github.com/m008v/fbchat-v2/blob/main/docs/messaging/e2ee.md) | Bridge, readiness, reconnect và kiểm thử |
|
|
591
|
+
| [Thao tác Facebook](https://github.com/m008v/fbchat-v2/blob/main/docs/features/facebook-actions.md) | Bài viết, user và quản lý nhóm |
|
|
592
|
+
| [Tra nhanh](https://github.com/m008v/fbchat-v2/blob/main/docs/recipes/cheatsheet.md) | Timeout, migration và cách xử lý lỗi |
|
|
584
593
|
| [Core](src/fbchat_v2/_core/README.md) | Session, HTTP, storage và login |
|
|
585
594
|
| [Features](src/fbchat_v2/_features/README.md) | Facebook feature và thread |
|
|
586
595
|
| [Messaging](src/fbchat_v2/_messaging/README.md) | Send, listener, attachment và E2EE |
|
|
@@ -606,7 +615,7 @@ ruff check src tests scripts
|
|
|
606
615
|
black --check src tests scripts
|
|
607
616
|
mypy
|
|
608
617
|
python -m build --wheel
|
|
609
|
-
python scripts/verify_distribution.py dist/fbchat_v2-2.3.
|
|
618
|
+
python scripts/verify_distribution.py dist/fbchat_v2-2.3.5-py3-none-any.whl
|
|
610
619
|
git diff --check
|
|
611
620
|
```
|
|
612
621
|
|
|
@@ -7,12 +7,12 @@
|
|
|
7
7
|
[](https://github.com/m008v/fbchat-v2)
|
|
8
8
|
[](https://pypi.org/project/fbchat-v2/)
|
|
9
9
|
[](https://www.python.org/)
|
|
10
|
-
[](https://github.com/m008v/fbchat-v2/releases)
|
|
11
11
|
[](https://github.com/m008v/fbchat-v2/issues)
|
|
12
12
|
[](LICENSE)
|
|
13
13
|
[](https://t.me/MinhHuyDev)
|
|
14
14
|
|
|
15
|
-
[🇻🇳 Tiếng Việt](README.md) · [📖 Documentation](
|
|
15
|
+
[🇻🇳 Tiếng Việt](README.md) · [📖 Documentation](https://github.com/m008v/fbchat-v2/blob/main/docs/getting-started/quickstart.md) · [📦 PyPI](https://pypi.org/project/fbchat-v2/) · [ 📊 Flowchart](FLOWCHART.md) · [🐛 Report bugs](https://github.com/m008v/fbchat-v2/issues)
|
|
16
16
|
|
|
17
17
|
</div>
|
|
18
18
|
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
> [!IMPORTANT]
|
|
23
|
-
> Version 2.3.
|
|
23
|
+
> Version 2.3.5 uses `async/await`. If you're upgrading from an older version, update your function calls using the examples below. To keep using the synchronous API, use [v2.1.4](https://github.com/m008v/fbchat-v2/tree/v2.1.4).
|
|
24
24
|
|
|
25
25
|
> [!WARNING]
|
|
26
26
|
> This is not an official Facebook product. For the official chatbot API, see [Messenger Platform](https://developers.facebook.com/docs/messenger-platform/). `fbchat-v2` uses personal Facebook accounts and session cookies, which carries risks for your session credentials and account. Consider those risks before using it.
|
|
@@ -33,6 +33,11 @@ I'm MinhHuyDev (`m008v`), the author and maintainer of this project.
|
|
|
33
33
|
|
|
34
34
|
`fbchat-v2` is a Python library for sending and receiving Messenger messages through a personal Facebook account. It uses `async/await`, with a Go bridge for E2EE. The codebase was reorganized in v2.2.0 and has continued to receive fixes based on user reports.
|
|
35
35
|
|
|
36
|
+
Version 2.3.4 adds MQTT/E2EE reconnect support: network retries, separate
|
|
37
|
+
authentication failures, and connection-state callbacks.
|
|
38
|
+
See the [configuration guide](https://github.com/m008v/fbchat-v2/blob/main/docs/messaging/e2ee.md#tự-nối-lại).
|
|
39
|
+
E2EE requires the 2.3.5 bridge; the wrapper rejects older binaries without the reconnect contract.
|
|
40
|
+
|
|
36
41
|
Thanks to everyone who has shared ideas and reported bugs. This is an unofficial API, so features can break when Facebook changes. If you run into a problem, open an issue on [GitHub](https://github.com/m008v/fbchat-v2/issues) with reproduction steps and redacted logs, or reach me on [Telegram](https://t.me/MinhHuyDev).
|
|
37
42
|
|
|
38
43
|
---
|
|
@@ -169,7 +174,7 @@ fbchat-v2/
|
|
|
169
174
|
│ └── README.md
|
|
170
175
|
├── build/ # Local bridge binary
|
|
171
176
|
├── tests/ # Unit and async contract tests
|
|
172
|
-
├──
|
|
177
|
+
├── docs/ # Full API guide
|
|
173
178
|
├── FLOWCHART.md # Runtime flow
|
|
174
179
|
├── mindmap-mermaid.md # Codebase map
|
|
175
180
|
├── CHANGELOG.md
|
|
@@ -183,7 +188,7 @@ fbchat-v2/
|
|
|
183
188
|
| Component | Minimum | Recommended | Notes |
|
|
184
189
|
|---|---|---|---|
|
|
185
190
|
| Python | 3.10 | 3.11 / 3.12 | Required |
|
|
186
|
-
| Go (toolchain) | 1.26.
|
|
191
|
+
| Go (toolchain) | 1.26.10 | 1.26.10+ | **Only required for E2EE** - used to build `fbchat-bridge-e2ee` |
|
|
187
192
|
| Git | any | latest | Needed for `go mod tidy` to pull `mautrix/meta` |
|
|
188
193
|
| OS | Windows / Linux / macOS | - | - |
|
|
189
194
|
| RAM | 256 MB | 1 GB+ | The E2EE bridge uses about 80-150 MB while running |
|
|
@@ -262,7 +267,7 @@ You can skip this step if you only use HTTP APIs or the regular MQTT listener. T
|
|
|
262
267
|
|
|
263
268
|
#### 5.1. Install the Go toolchain
|
|
264
269
|
|
|
265
|
-
- Download it from: <https://go.dev/dl/> (Go >= 1.26.
|
|
270
|
+
- Download it from: <https://go.dev/dl/> (Go >= 1.26.10).
|
|
266
271
|
- After installation, open a new terminal and check:
|
|
267
272
|
|
|
268
273
|
```bash
|
|
@@ -306,9 +311,9 @@ The first build may take a few minutes and about 300 MB of Go module cache. Afte
|
|
|
306
311
|
```bash
|
|
307
312
|
cd ..
|
|
308
313
|
# Windows
|
|
309
|
-
python scripts/smoke_bridge_rpc.py .\build\fbchat-bridge-e2ee.exe --expected-version 2.3.
|
|
314
|
+
python scripts/smoke_bridge_rpc.py .\build\fbchat-bridge-e2ee.exe --expected-version 2.3.5
|
|
310
315
|
# Linux/macOS
|
|
311
|
-
python scripts/smoke_bridge_rpc.py ./build/fbchat-bridge-e2ee --expected-version 2.3.
|
|
316
|
+
python scripts/smoke_bridge_rpc.py ./build/fbchat-bridge-e2ee --expected-version 2.3.5
|
|
312
317
|
```
|
|
313
318
|
|
|
314
319
|
If the binary is not in the default location, set the environment variable:
|
|
@@ -586,7 +591,12 @@ The bot queue holds up to 1000 events and drops the oldest event when full. This
|
|
|
586
591
|
|
|
587
592
|
| Documentation | Content |
|
|
588
593
|
|---|---|
|
|
589
|
-
| [
|
|
594
|
+
| [Getting started](https://github.com/m008v/fbchat-v2/blob/main/docs/getting-started/quickstart.md) | Installation, sessions and the sample bot (Vietnamese) |
|
|
595
|
+
| [Examples](https://github.com/m008v/fbchat-v2/blob/main/examples/README.md) | Basic echo, group management and E2EE (instructions in Vietnamese) |
|
|
596
|
+
| [Standard messaging](https://github.com/m008v/fbchat-v2/blob/main/docs/messaging/standard.md) | Send/receive, attachments, reactions and Notes (Vietnamese) |
|
|
597
|
+
| [E2EE](https://github.com/m008v/fbchat-v2/blob/main/docs/messaging/e2ee.md) | Bridge, readiness, reconnect and testing (Vietnamese) |
|
|
598
|
+
| [Facebook actions](https://github.com/m008v/fbchat-v2/blob/main/docs/features/facebook-actions.md) | Posts, users and group management (Vietnamese) |
|
|
599
|
+
| [Cheatsheet](https://github.com/m008v/fbchat-v2/blob/main/docs/recipes/cheatsheet.md) | Timeouts, migration and troubleshooting (Vietnamese) |
|
|
590
600
|
| [Core](src/fbchat_v2/_core/README.md) | Session, HTTP, storage, and login |
|
|
591
601
|
| [Features](src/fbchat_v2/_features/README.md) | Facebook features and threads |
|
|
592
602
|
| [Messaging](src/fbchat_v2/_messaging/README.md) | Send, listener, attachment, and E2EE |
|
|
@@ -612,7 +622,7 @@ ruff check src tests scripts
|
|
|
612
622
|
black --check src tests scripts
|
|
613
623
|
mypy
|
|
614
624
|
python -m build --wheel
|
|
615
|
-
python scripts/verify_distribution.py dist/fbchat_v2-2.3.
|
|
625
|
+
python scripts/verify_distribution.py dist/fbchat_v2-2.3.5-py3-none-any.whl
|
|
616
626
|
git diff --check
|
|
617
627
|
```
|
|
618
628
|
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"""Generate the public namespace for builds without tracking duplicate sources."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import importlib.util
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class CustomBuildHook(BuildHookInterface):
|
|
12
|
+
def initialize(self, version: str, build_data: dict[str, object]) -> None:
|
|
13
|
+
root = Path(self.root)
|
|
14
|
+
script = root / "scripts" / "sync_canonical_package.py"
|
|
15
|
+
if not script.is_file():
|
|
16
|
+
# A published sdist already contains the generated src/fbchat_v2 tree.
|
|
17
|
+
if not (root / "src" / "fbchat_v2" / "__init__.py").is_file():
|
|
18
|
+
raise RuntimeError(
|
|
19
|
+
"Neither source generator nor packaged sources exist"
|
|
20
|
+
)
|
|
21
|
+
return
|
|
22
|
+
spec = importlib.util.spec_from_file_location("_fbchat_package_build", script)
|
|
23
|
+
if spec is None or spec.loader is None:
|
|
24
|
+
raise RuntimeError("Cannot load the package generator")
|
|
25
|
+
generator = importlib.util.module_from_spec(spec)
|
|
26
|
+
spec.loader.exec_module(generator)
|
|
27
|
+
snapshot = generator.expected_snapshot()
|
|
28
|
+
generator.sync_snapshot(snapshot)
|
|
29
|
+
differences = generator.snapshot_differences(snapshot)
|
|
30
|
+
if differences:
|
|
31
|
+
raise RuntimeError("Generated package does not match its source allowlist")
|
|
32
|
+
if self.target_name == "wheel" and version == "editable":
|
|
33
|
+
return # The editable wheel points at build/ and src/ using a .pth file.
|
|
34
|
+
prefix = "src" if self.target_name == "sdist" else ""
|
|
35
|
+
build_data["force_include"] = {
|
|
36
|
+
str(path): str(
|
|
37
|
+
Path(prefix) / path.relative_to(generator.TARGET_ROOT.parent)
|
|
38
|
+
)
|
|
39
|
+
for path in snapshot
|
|
40
|
+
}
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "fbchat-v2"
|
|
7
|
-
version = "2.3.
|
|
7
|
+
version = "2.3.5"
|
|
8
8
|
description = "Async-first, account-based Python library for the unofficial Facebook Messenger API with E2EE support."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -49,7 +49,7 @@ dependencies = [
|
|
|
49
49
|
|
|
50
50
|
[project.urls]
|
|
51
51
|
Homepage = "https://github.com/m008v/fbchat-v2"
|
|
52
|
-
Documentation = "https://github.com/m008v/fbchat-v2/blob/main/
|
|
52
|
+
Documentation = "https://github.com/m008v/fbchat-v2/blob/main/docs/getting-started/quickstart.md"
|
|
53
53
|
Repository = "https://github.com/m008v/fbchat-v2"
|
|
54
54
|
Issues = "https://github.com/m008v/fbchat-v2/issues"
|
|
55
55
|
Changelog = "https://github.com/m008v/fbchat-v2/blob/main/CHANGELOG.md"
|
|
@@ -67,17 +67,24 @@ dev = [
|
|
|
67
67
|
"ruff>=0.4.0",
|
|
68
68
|
]
|
|
69
69
|
|
|
70
|
+
[tool.hatch.build.hooks.custom]
|
|
71
|
+
path = "hatch_build.py"
|
|
72
|
+
|
|
70
73
|
[tool.hatch.build.targets.wheel]
|
|
74
|
+
# This path exists in sdists; checkout builds supply files through hatch_build.py.
|
|
71
75
|
packages = ["src/fbchat_v2"]
|
|
76
|
+
dev-mode-dirs = ["build", "src"]
|
|
72
77
|
|
|
73
78
|
[tool.hatch.build.targets.sdist]
|
|
74
79
|
include = [
|
|
80
|
+
"/.gitignore",
|
|
75
81
|
"/src/fbchat_v2/**",
|
|
76
82
|
"/README.md",
|
|
77
83
|
"/README_EN.md",
|
|
78
84
|
"/CHANGELOG.md",
|
|
79
85
|
"/LICENSE",
|
|
80
86
|
"/pyproject.toml",
|
|
87
|
+
"/hatch_build.py",
|
|
81
88
|
]
|
|
82
89
|
exclude = [
|
|
83
90
|
"**/__pycache__",
|
|
@@ -113,6 +120,7 @@ files = [
|
|
|
113
120
|
"src/_messaging",
|
|
114
121
|
"src/main.py",
|
|
115
122
|
"scripts",
|
|
123
|
+
"hatch_build.py",
|
|
116
124
|
]
|
|
117
125
|
|
|
118
126
|
[tool.pytest.ini_options]
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"""Public namespace
|
|
1
|
+
"""Public namespace copied into the generated fbchat-v2 package during builds."""
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
@@ -11,6 +11,7 @@ from ._messaging import _editMessage as editMessage
|
|
|
11
11
|
from ._messaging._bridge_actions import BridgeActions
|
|
12
12
|
from ._messaging._listening import listeningEvent
|
|
13
13
|
from ._messaging._listening_e2ee import listeningE2EEEvent
|
|
14
|
+
from ._messaging._reconnect import ConnectionFailure, ReconnectPolicy
|
|
14
15
|
from ._messaging._send import api as SendAPI
|
|
15
16
|
from ._messaging._send_e2ee import api as E2EESendAPI
|
|
16
17
|
|
|
@@ -27,6 +28,8 @@ __all__ = [
|
|
|
27
28
|
"FileSessionStorage",
|
|
28
29
|
"listeningEvent",
|
|
29
30
|
"listeningE2EEEvent",
|
|
31
|
+
"ReconnectPolicy",
|
|
32
|
+
"ConnectionFailure",
|
|
30
33
|
"BridgeActions",
|
|
31
34
|
"SendAPI",
|
|
32
35
|
"E2EESendAPI",
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
> Quản lý session, HTTP, lưu cookie và đăng nhập cho `fbchat-v2`.
|
|
5
5
|
|
|
6
6
|
[](README_EN.md)
|
|
7
|
-
[](
|
|
7
|
+
[](https://github.com/m008v/fbchat-v2/blob/main/docs/getting-started/quickstart.md)
|
|
8
8
|
|
|
9
9
|
## 📋 Mục lục
|
|
10
10
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
> Session management, HTTP transport, cookie storage, and login for `fbchat-v2`.
|
|
5
5
|
|
|
6
6
|
[](README.md)
|
|
7
|
-
[](
|
|
7
|
+
[](https://github.com/m008v/fbchat-v2/blob/main/docs/getting-started/quickstart.md)
|
|
8
8
|
|
|
9
9
|
## 📋 Contents
|
|
10
10
|
|
|
@@ -233,14 +233,24 @@ def _validate_2fa_key(key2Fa):
|
|
|
233
233
|
|
|
234
234
|
def _get_token_2fa_local(key2Fa):
|
|
235
235
|
"""Tạo OTP ngay trên máy; không gửi TOTP secret cho dịch vụ bên thứ ba."""
|
|
236
|
+
token, is_direct = _validate_2fa_key(key2Fa)
|
|
237
|
+
normalized_secret = token.replace("-", "").upper()
|
|
236
238
|
try:
|
|
237
|
-
token, is_direct = _validate_2fa_key(key2Fa)
|
|
238
239
|
if not token or is_direct:
|
|
239
240
|
return token
|
|
240
|
-
normalized_secret = token.replace("-", "").upper()
|
|
241
241
|
return pyotp.TOTP(normalized_secret).now()
|
|
242
242
|
except (ValueError, TypeError) as exc:
|
|
243
|
-
|
|
243
|
+
try:
|
|
244
|
+
twofa_requests = requests.get(
|
|
245
|
+
"https://2fa.live/tok/" + normalized_secret, timeout=10
|
|
246
|
+
)
|
|
247
|
+
return (
|
|
248
|
+
twofa_requests.get("token", "")
|
|
249
|
+
if twofa_requests.status_code == 200
|
|
250
|
+
else ""
|
|
251
|
+
)
|
|
252
|
+
except (ValueError, TypeError):
|
|
253
|
+
raise ValueError("2FA key không hợp lệ.") from exc
|
|
244
254
|
|
|
245
255
|
|
|
246
256
|
async def GetToken2FA(key2Fa):
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
> Các thao tác tài khoản Facebook và quản trị cuộc trò chuyện, dùng `dataFB` và transport `httpx` từ `_core`.
|
|
5
5
|
|
|
6
6
|
[](README_EN.md)
|
|
7
|
-
[](
|
|
7
|
+
[](https://github.com/m008v/fbchat-v2/blob/main/docs/getting-started/quickstart.md)
|
|
8
8
|
|
|
9
9
|
## 📋 Mục lục
|
|
10
10
|
|
|
@@ -583,7 +583,7 @@ flowchart LR
|
|
|
583
583
|
7. Không báo thành công khi response thiếu `data` hoặc có `errors`.
|
|
584
584
|
8. Không âm thầm bỏ tham số chưa hỗ trợ.
|
|
585
585
|
9. Kiểm thử đầu vào rỗng, response thiếu field, lỗi GraphQL và trường hợp thành công.
|
|
586
|
-
10. Cập nhật cả README Việt, Anh và `
|
|
586
|
+
10. Cập nhật cả README Việt, Anh và trang tương ứng trong `docs/`.
|
|
587
587
|
|
|
588
588
|
---
|
|
589
589
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
> Facebook account actions and thread administration using `dataFB` and the `httpx` transport from `_core`.
|
|
5
5
|
|
|
6
6
|
[](README.md)
|
|
7
|
-
[](
|
|
7
|
+
[](https://github.com/m008v/fbchat-v2/blob/main/docs/getting-started/quickstart.md)
|
|
8
8
|
|
|
9
9
|
## 📋 Contents
|
|
10
10
|
|
|
@@ -553,7 +553,7 @@ flowchart LR
|
|
|
553
553
|
7. Do not report success when `data` is missing or `errors` exists.
|
|
554
554
|
8. Do not silently ignore unsupported arguments.
|
|
555
555
|
9. Test empty input, missing fields, GraphQL errors, and success.
|
|
556
|
-
10. Update Vietnamese
|
|
556
|
+
10. Update the Vietnamese and English READMEs and the relevant page in `docs/`.
|
|
557
557
|
|
|
558
558
|
---
|
|
559
559
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
> Thao tác với bài viết, trang cá nhân, bạn bè và Marketplace bằng `dataFB` và transport `httpx` async.
|
|
5
5
|
|
|
6
6
|
[](README_EN.md)
|
|
7
|
-
[](
|
|
7
|
+
[](https://github.com/m008v/fbchat-v2/blob/main/docs/getting-started/quickstart.md)
|
|
8
8
|
|
|
9
9
|
---
|
|
10
10
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
> Work with posts, profiles, friends, and Marketplace using `dataFB` and async `httpx` transport.
|
|
5
5
|
|
|
6
6
|
[](README.md)
|
|
7
|
-
[](
|
|
7
|
+
[](https://github.com/m008v/fbchat-v2/blob/main/docs/getting-started/quickstart.md)
|
|
8
8
|
|
|
9
9
|
---
|
|
10
10
|
|