chat-easy 0.1.0__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.
- chat_easy-0.1.0/PKG-INFO +7 -0
- chat_easy-0.1.0/chat/__init__.py +65 -0
- chat_easy-0.1.0/chat/main.py +57 -0
- chat_easy-0.1.0/chat_easy.egg-info/PKG-INFO +7 -0
- chat_easy-0.1.0/chat_easy.egg-info/SOURCES.txt +8 -0
- chat_easy-0.1.0/chat_easy.egg-info/dependency_links.txt +1 -0
- chat_easy-0.1.0/chat_easy.egg-info/entry_points.txt +2 -0
- chat_easy-0.1.0/chat_easy.egg-info/top_level.txt +1 -0
- chat_easy-0.1.0/pyproject.toml +16 -0
- chat_easy-0.1.0/setup.cfg +4 -0
chat_easy-0.1.0/PKG-INFO
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}'")
|
|
@@ -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 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
chat
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "chat-easy"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Background-persisted custom chat library"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.8"
|
|
11
|
+
authors = [
|
|
12
|
+
{ name = "Atharva" }
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
[project.scripts]
|
|
16
|
+
prepare = "chat.cli:main"
|