stvtermux 1.0.6__tar.gz → 1.0.8__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.
- {stvtermux-1.0.6 → stvtermux-1.0.8}/PKG-INFO +1 -1
- {stvtermux-1.0.6 → stvtermux-1.0.8}/setup.py +1 -1
- {stvtermux-1.0.6 → stvtermux-1.0.8}/stvtermux/cli.py +1 -1
- {stvtermux-1.0.6 → stvtermux-1.0.8}/stvtermux/core.py +11 -9
- stvtermux-1.0.8/stvtermux/nhom.py +69 -0
- {stvtermux-1.0.6 → stvtermux-1.0.8}/stvtermux.egg-info/PKG-INFO +1 -1
- stvtermux-1.0.6/stvtermux/nhom.py +0 -1
- {stvtermux-1.0.6 → stvtermux-1.0.8}/README.md +0 -0
- {stvtermux-1.0.6 → stvtermux-1.0.8}/pyproject.toml +0 -0
- {stvtermux-1.0.6 → stvtermux-1.0.8}/setup.cfg +0 -0
- {stvtermux-1.0.6 → stvtermux-1.0.8}/stvtermux/__init__.py +0 -0
- {stvtermux-1.0.6 → stvtermux-1.0.8}/stvtermux/index.py +0 -0
- {stvtermux-1.0.6 → stvtermux-1.0.8}/stvtermux.egg-info/SOURCES.txt +0 -0
- {stvtermux-1.0.6 → stvtermux-1.0.8}/stvtermux.egg-info/dependency_links.txt +0 -0
- {stvtermux-1.0.6 → stvtermux-1.0.8}/stvtermux.egg-info/entry_points.txt +0 -0
- {stvtermux-1.0.6 → stvtermux-1.0.8}/stvtermux.egg-info/requires.txt +0 -0
- {stvtermux-1.0.6 → stvtermux-1.0.8}/stvtermux.egg-info/top_level.txt +0 -0
@@ -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: ")
|
@@ -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
|
+
|
@@ -0,0 +1,69 @@
|
|
1
|
+
import requests
|
2
|
+
import threading
|
3
|
+
import time
|
4
|
+
import json
|
5
|
+
import os
|
6
|
+
|
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
|
+
|
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
|
23
|
+
def listen_messages():
|
24
|
+
last_data = None
|
25
|
+
while True:
|
26
|
+
try:
|
27
|
+
res = requests.get(FIREBASE_CHAT)
|
28
|
+
if res.status_code == 200:
|
29
|
+
data = res.json() or {}
|
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)
|
39
|
+
time.sleep(2)
|
40
|
+
|
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
|
50
|
+
|
51
|
+
name = get_name(user_id)
|
52
|
+
print(f"👋 Xin chào {name}, bạn đã vào nhóm chat!")
|
53
|
+
|
54
|
+
threading.Thread(target=listen_messages, daemon=True).start()
|
55
|
+
|
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
|
61
|
+
|
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)
|
67
|
+
|
68
|
+
if __name__ == "__main__":
|
69
|
+
chat()
|
@@ -1 +0,0 @@
|
|
1
|
-
print("🎉 Xin chào! Bạn đã vào file nhóm.py")
|
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
|