stvtermux 1.0.7__py3-none-any.whl → 1.0.8__py3-none-any.whl
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.
- stvtermux/cli.py +1 -1
- stvtermux/core.py +11 -9
- stvtermux/nhom.py +50 -34
- {stvtermux-1.0.7.dist-info → stvtermux-1.0.8.dist-info}/METADATA +1 -1
- stvtermux-1.0.8.dist-info/RECORD +10 -0
- stvtermux-1.0.7.dist-info/RECORD +0 -10
- {stvtermux-1.0.7.dist-info → stvtermux-1.0.8.dist-info}/WHEEL +0 -0
- {stvtermux-1.0.7.dist-info → stvtermux-1.0.8.dist-info}/entry_points.txt +0 -0
- {stvtermux-1.0.7.dist-info → stvtermux-1.0.8.dist-info}/top_level.txt +0 -0
stvtermux/cli.py
CHANGED
@@ -5,7 +5,7 @@ def main():
|
|
5
5
|
|
6
6
|
print("===== 🌐 STVTermux Login System 🌐 =====")
|
7
7
|
while True:
|
8
|
-
choice = input("👉 Bạn muốn:\n(1) Đăng ký hay\n(2) Đăng nhập
|
8
|
+
choice = input("👉 Bạn muốn:\n(1) Đăng ký hay\n(2) Đăng nhập ")
|
9
9
|
if choice == "1":
|
10
10
|
u = input("username: ")
|
11
11
|
p = input("password: ")
|
stvtermux/core.py
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
import requests
|
2
2
|
import json
|
3
3
|
import subprocess
|
4
|
-
import os
|
5
4
|
|
6
5
|
FIREBASE_URL = "https://sever-login-ae5cc-default-rtdb.firebaseio.com/player.json"
|
7
6
|
|
@@ -29,20 +28,23 @@ class Auth:
|
|
29
28
|
print("❌ Đăng ký thất bại!")
|
30
29
|
return False
|
31
30
|
|
32
|
-
def login(self, username: str, password: str)
|
31
|
+
def login(self, username: str, password: str):
|
33
32
|
res = requests.get(self.firebase_url)
|
34
33
|
if res.status_code != 200:
|
35
34
|
print("❌ Lỗi kết nối server!")
|
36
|
-
return
|
35
|
+
return None
|
37
36
|
|
38
37
|
data = res.json() or {}
|
39
|
-
for
|
38
|
+
for user_id, user in data.items():
|
40
39
|
if user.get("username") == username and user.get("password") == password:
|
41
40
|
print("✅ Đăng nhập thành công!")
|
42
|
-
#
|
43
|
-
|
44
|
-
|
45
|
-
|
41
|
+
# Ghi user_id ra file tạm để nhom.py đọc
|
42
|
+
with open("user.json", "w", encoding="utf-8") as f:
|
43
|
+
json.dump({"user_id": user_id}, f)
|
44
|
+
subprocess.run(["python", "index.py"])
|
45
|
+
return user_id
|
46
46
|
|
47
47
|
print("❌ Sai username hoặc password!")
|
48
|
-
return
|
48
|
+
return None
|
49
|
+
|
50
|
+
|
stvtermux/nhom.py
CHANGED
@@ -1,53 +1,69 @@
|
|
1
1
|
import requests
|
2
|
-
import json
|
3
2
|
import threading
|
4
3
|
import time
|
4
|
+
import json
|
5
5
|
import os
|
6
|
-
import sys
|
7
6
|
|
8
|
-
|
7
|
+
FIREBASE_CHAT = "https://sever-login-ae5cc-default-rtdb.firebaseio.com/chatnhom.json"
|
8
|
+
FIREBASE_PLAYER = "https://sever-login-ae5cc-default-rtdb.firebaseio.com/player.json"
|
9
9
|
|
10
|
+
# Lấy tên user từ player.json dựa vào user_id
|
11
|
+
def get_name(user_id: str) -> str:
|
12
|
+
try:
|
13
|
+
res = requests.get(FIREBASE_PLAYER)
|
14
|
+
if res.status_code != 200:
|
15
|
+
return "Ẩn danh"
|
16
|
+
data = res.json() or {}
|
17
|
+
user = data.get(user_id, {})
|
18
|
+
return user.get("username", "Ẩn danh")
|
19
|
+
except Exception:
|
20
|
+
return "Ẩn danh"
|
21
|
+
|
22
|
+
# Luồng hiển thị tin nhắn
|
10
23
|
def listen_messages():
|
11
|
-
|
24
|
+
last_data = None
|
12
25
|
while True:
|
13
26
|
try:
|
14
|
-
res = requests.get(
|
27
|
+
res = requests.get(FIREBASE_CHAT)
|
15
28
|
if res.status_code == 200:
|
16
29
|
data = res.json() or {}
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
30
|
+
if data != last_data:
|
31
|
+
os.system("clear")
|
32
|
+
print("===== 💬 Tin nhắn nhóm =====")
|
33
|
+
for _, msg in data.items():
|
34
|
+
print(f"[{msg.get('name')}] {msg.get('text')}")
|
35
|
+
print("============================")
|
36
|
+
last_data = data
|
37
|
+
except Exception as e:
|
38
|
+
print("❌ Lỗi khi lấy tin nhắn:", e)
|
24
39
|
time.sleep(2)
|
25
40
|
|
26
|
-
def
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
print("❌ Lỗi gửi tin nhắn!")
|
41
|
+
def chat():
|
42
|
+
# Đọc user_id từ file user.json
|
43
|
+
try:
|
44
|
+
with open("user.json", "r", encoding="utf-8") as f:
|
45
|
+
user_data = json.load(f)
|
46
|
+
user_id = user_data.get("user_id")
|
47
|
+
except FileNotFoundError:
|
48
|
+
print("❌ Bạn chưa đăng nhập!")
|
49
|
+
return
|
36
50
|
|
37
|
-
|
38
|
-
|
39
|
-
print("══════════════════════════════════════")
|
40
|
-
print("🌐 CHAT NHÓM STVTermux (Realtime) 🌐")
|
41
|
-
print("══════════════════════════════════════")
|
51
|
+
name = get_name(user_id)
|
52
|
+
print(f"👋 Xin chào {name}, bạn đã vào nhóm chat!")
|
42
53
|
|
43
|
-
|
44
|
-
name = sys.argv[1] if len(sys.argv) > 1 else "Ẩn danh"
|
54
|
+
threading.Thread(target=listen_messages, daemon=True).start()
|
45
55
|
|
46
|
-
|
47
|
-
|
56
|
+
while True:
|
57
|
+
text = input("✍️ Nhập tin nhắn: ")
|
58
|
+
if text.lower() in ["exit", "quit"]:
|
59
|
+
print("👋 Thoát nhóm chat...")
|
60
|
+
break
|
48
61
|
|
49
|
-
|
50
|
-
|
62
|
+
msg = {"name": name, "text": text}
|
63
|
+
try:
|
64
|
+
requests.post(FIREBASE_CHAT, data=json.dumps(msg))
|
65
|
+
except Exception as e:
|
66
|
+
print("❌ Lỗi gửi tin nhắn:", e)
|
51
67
|
|
52
68
|
if __name__ == "__main__":
|
53
|
-
|
69
|
+
chat()
|
@@ -0,0 +1,10 @@
|
|
1
|
+
stvtermux/__init__.py,sha256=bk7kIC3tSACeEbiYSYrJEpHxwr6DswGbO-18EF-MDwM,45
|
2
|
+
stvtermux/cli.py,sha256=hpK610GHWzm526R3M6H5zlFdxgcWjBcLbm7lXZdK5K4,543
|
3
|
+
stvtermux/core.py,sha256=WN6F7EBvZcgQMV5KHbGZGNXofUeuYm2qqLIHt624D4I,1809
|
4
|
+
stvtermux/index.py,sha256=QazhR3QhyKZO3Uc3x_TapRCduCStOtxWT2HY5xfQ5gY,999
|
5
|
+
stvtermux/nhom.py,sha256=QsGAp-hdTUa2HBaieG1XwQwLPTaG7cxjPdnMfDTDrXE,2262
|
6
|
+
stvtermux-1.0.8.dist-info/METADATA,sha256=oM6WAiRnewg8jwuVyvZ4Usegi0OhGnK8TnzkI_-HKRs,100
|
7
|
+
stvtermux-1.0.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
8
|
+
stvtermux-1.0.8.dist-info/entry_points.txt,sha256=7b0IuLqKSWL2VMJxcTdMLZXBaPfYT1atz6wwBTqco9Q,43
|
9
|
+
stvtermux-1.0.8.dist-info/top_level.txt,sha256=6krSSYES7OG83FeLt7MWD5vG8MOwzYh_K3ju8lBNqwg,10
|
10
|
+
stvtermux-1.0.8.dist-info/RECORD,,
|
stvtermux-1.0.7.dist-info/RECORD
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
stvtermux/__init__.py,sha256=bk7kIC3tSACeEbiYSYrJEpHxwr6DswGbO-18EF-MDwM,45
|
2
|
-
stvtermux/cli.py,sha256=pmjeY6GyZMqPiXN_lzdrScaG5gBFtS7EHlhmb_Ld1PM,544
|
3
|
-
stvtermux/core.py,sha256=mTFyeko7yw9b38ZV6mDMcWC7L83Rbn3cPjAJUi2xhHY,1798
|
4
|
-
stvtermux/index.py,sha256=QazhR3QhyKZO3Uc3x_TapRCduCStOtxWT2HY5xfQ5gY,999
|
5
|
-
stvtermux/nhom.py,sha256=R-J804aLE7HN_oU_gYBkX3Zkqzy7J7p7FPyKrPY__G8,1736
|
6
|
-
stvtermux-1.0.7.dist-info/METADATA,sha256=xBA2iI91BvCKvAk9ZVa8f1aVC0BdQbUoLcYgM_IjfSI,100
|
7
|
-
stvtermux-1.0.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
8
|
-
stvtermux-1.0.7.dist-info/entry_points.txt,sha256=7b0IuLqKSWL2VMJxcTdMLZXBaPfYT1atz6wwBTqco9Q,43
|
9
|
-
stvtermux-1.0.7.dist-info/top_level.txt,sha256=6krSSYES7OG83FeLt7MWD5vG8MOwzYh_K3ju8lBNqwg,10
|
10
|
-
stvtermux-1.0.7.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|