stvtermux 1.0.6__tar.gz → 1.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.
@@ -1,5 +1,5 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: stvtermux
3
- Version: 1.0.6
3
+ Version: 1.0.7
4
4
  Requires-Dist: requests
5
5
  Dynamic: requires-dist
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="stvtermux",
5
- version="1.0.6",
5
+ version="1.0.7",
6
6
  packages=find_packages(),
7
7
  install_requires=["requests"],
8
8
  entry_points={
@@ -0,0 +1,53 @@
1
+ import requests
2
+ import json
3
+ import threading
4
+ import time
5
+ import os
6
+ import sys
7
+
8
+ FIREBASE_URL = "https://sever-login-ae5cc-default-rtdb.firebaseio.com/chatnhom.json"
9
+
10
+ def listen_messages():
11
+ last_seen = None
12
+ while True:
13
+ try:
14
+ res = requests.get(FIREBASE_URL)
15
+ if res.status_code == 200:
16
+ data = res.json() or {}
17
+ sorted_msgs = sorted(data.items(), key=lambda x: x[0])
18
+ for k, v in sorted_msgs:
19
+ if last_seen is None or k > last_seen:
20
+ print(f"\n💬 {v.get('name')}: {v.get('msg')}")
21
+ last_seen = k
22
+ except Exception:
23
+ pass
24
+ time.sleep(2)
25
+
26
+ def send_message(name):
27
+ while True:
28
+ msg = input("")
29
+ if msg.strip() == "":
30
+ continue
31
+ data = {"name": name, "msg": msg}
32
+ try:
33
+ requests.post(FIREBASE_URL, data=json.dumps(data))
34
+ except Exception:
35
+ print("❌ Lỗi gửi tin nhắn!")
36
+
37
+ def main():
38
+ os.system("clear")
39
+ print("══════════════════════════════════════")
40
+ print("🌐 CHAT NHÓM STVTermux (Realtime) 🌐")
41
+ print("══════════════════════════════════════")
42
+
43
+ # 👉 lấy tên từ sys.argv (username đã login)
44
+ name = sys.argv[1] if len(sys.argv) > 1 else "Ẩn danh"
45
+
46
+ t = threading.Thread(target=listen_messages, daemon=True)
47
+ t.start()
48
+
49
+ print(f"✨ {name}, bắt đầu trò chuyện...")
50
+ send_message(name)
51
+
52
+ if __name__ == "__main__":
53
+ main()
@@ -1,5 +1,5 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: stvtermux
3
- Version: 1.0.6
3
+ Version: 1.0.7
4
4
  Requires-Dist: requests
5
5
  Dynamic: requires-dist
@@ -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