chat-easy 0.1.0__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.
chat/__init__.py ADDED
@@ -0,0 +1,65 @@
1
+ import os
2
+ import json
3
+ import random
4
+ import string
5
+
6
+ STORAGE_FILE = os.path.join(os.path.expanduser("~"), "chat_library_data.json")
7
+
8
+ # Variable defaults
9
+ chat_code = None
10
+ previos_resived = []
11
+ get_sent_messges = []
12
+
13
+ def _load_data():
14
+ if not os.path.exists(STORAGE_FILE):
15
+ return {
16
+ "key": None,
17
+ "chat_code": None,
18
+ "received_messages": [],
19
+ "sent_messages": []
20
+ }
21
+ with open(STORAGE_FILE, "r", encoding="utf-8") as f:
22
+ return json.load(f)
23
+
24
+ def _save_data(data):
25
+ with open(STORAGE_FILE, "w", encoding="utf-8") as f:
26
+ json.dump(data, f, indent=4)
27
+
28
+ def conneckt(actual_key):
29
+ global chat_code, previos_resived, get_sent_messges
30
+
31
+ data = _load_data()
32
+ data["key"] = actual_key
33
+
34
+ if not data["chat_code"]:
35
+ data["chat_code"] = "CHAT-" + "".join(random.choices(string.digits, k=4))
36
+
37
+ _save_data(data)
38
+
39
+ # Update package variables directly using global scope
40
+ chat_code = data["chat_code"]
41
+ previos_resived = data["received_messages"]
42
+ get_sent_messges = data["sent_messages"]
43
+
44
+ print("Connected successfully!")
45
+ print(f"Your Chat Code: {chat_code}")
46
+ return chat_code
47
+
48
+ def send_chat(text):
49
+ global get_sent_messges
50
+
51
+ data = _load_data()
52
+ if not data["chat_code"]:
53
+ print("Error: Call conneckt() first!")
54
+ return
55
+
56
+ sent_entry = {
57
+ "from_code": data["chat_code"],
58
+ "message": text
59
+ }
60
+
61
+ data["sent_messages"].append(sent_entry)
62
+ _save_data(data)
63
+
64
+ get_sent_messges = data["sent_messages"]
65
+ print(f"Message sent: '{text}'")
chat/main.py ADDED
@@ -0,0 +1,57 @@
1
+ import os
2
+ import json
3
+ import random
4
+ import string
5
+ import chat # Import the package itself to set attributes directly on it
6
+
7
+ STORAGE_FILE = os.path.join(os.path.expanduser("~"), "chat_library_data.json")
8
+
9
+ def _load_data():
10
+ if not os.path.exists(STORAGE_FILE):
11
+ return {
12
+ "key": None,
13
+ "chat_code": None,
14
+ "received_messages": [],
15
+ "sent_messages": []
16
+ }
17
+ with open(STORAGE_FILE, "r", encoding="utf-8") as f:
18
+ return json.load(f)
19
+
20
+ def _save_data(data):
21
+ with open(STORAGE_FILE, "w", encoding="utf-8") as f:
22
+ json.dump(data, f, indent=4)
23
+
24
+ def conneckt(actual_key):
25
+ data = _load_data()
26
+ data["key"] = actual_key
27
+
28
+ if not data["chat_code"]:
29
+ data["chat_code"] = "CHAT-" + "".join(random.choices(string.digits, k=4))
30
+
31
+ _save_data(data)
32
+
33
+ # Update attributes on the chat module directly
34
+ chat.chat_code = data["chat_code"]
35
+ chat.previos_resived = data["received_messages"]
36
+ chat.get_sent_messges = data["sent_messages"]
37
+
38
+ print("Connected successfully!")
39
+ print(f"Your Chat Code: {data['chat_code']}")
40
+ return data["chat_code"]
41
+
42
+ def send_chat(text):
43
+ data = _load_data()
44
+ if not data["chat_code"]:
45
+ print("Error: Call conneckt() first!")
46
+ return
47
+
48
+ sent_entry = {
49
+ "from_code": data["chat_code"],
50
+ "message": text
51
+ }
52
+
53
+ data["sent_messages"].append(sent_entry)
54
+ _save_data(data)
55
+
56
+ chat.get_sent_messges = data["sent_messages"]
57
+ print(f"Message sent: '{text}'")
@@ -0,0 +1,7 @@
1
+ Metadata-Version: 2.4
2
+ Name: chat-easy
3
+ Version: 0.1.0
4
+ Summary: Background-persisted custom chat library
5
+ Author: Atharva
6
+ Requires-Python: >=3.8
7
+ Description-Content-Type: text/markdown
@@ -0,0 +1,7 @@
1
+ chat/__init__.py,sha256=ZGfK0pHMdKOxN0QdsJVV6CAZPMMm0vr9WglRFS_zKtU,1695
2
+ chat/main.py,sha256=WEz46lIvGV5jLQJbrV_hq7L4HN4Lct7GwuMwXlE9OD8,1615
3
+ chat_easy-0.1.0.dist-info/METADATA,sha256=xLx8hJsmvpzKE_igZ3V0e5AjAUF0Xjp256VVEs4aiRY,189
4
+ chat_easy-0.1.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
5
+ chat_easy-0.1.0.dist-info/entry_points.txt,sha256=DKkM9BP13a9XxZxWWoq0_O5fvj9wabdeY29_rYsIQE4,42
6
+ chat_easy-0.1.0.dist-info/top_level.txt,sha256=0Dp7qDRFfIFYBhe5CqxvZQUjL1VpUvy3-rs6dAscIXA,5
7
+ chat_easy-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ prepare = chat.cli:main
@@ -0,0 +1 @@
1
+ chat