wnox 0.8.0__tar.gz → 1.0.0__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {wnox-0.8.0 → wnox-1.0.0}/PKG-INFO +3 -2
- {wnox-0.8.0 → wnox-1.0.0}/pyproject.toml +2 -2
- {wnox-0.8.0 → wnox-1.0.0}/setup.py +1 -1
- {wnox-0.8.0 → wnox-1.0.0}/wnox/__init__.py +90 -13
- {wnox-0.8.0 → wnox-1.0.0}/wnox.egg-info/PKG-INFO +3 -2
- wnox-1.0.0/wnox.egg-info/requires.txt +3 -0
- wnox-0.8.0/wnox.egg-info/requires.txt +0 -2
- {wnox-0.8.0 → wnox-1.0.0}/LICENSE.txt +0 -0
- {wnox-0.8.0 → wnox-1.0.0}/README.md +0 -0
- {wnox-0.8.0 → wnox-1.0.0}/setup.cfg +0 -0
- {wnox-0.8.0 → wnox-1.0.0}/wnox.egg-info/SOURCES.txt +0 -0
- {wnox-0.8.0 → wnox-1.0.0}/wnox.egg-info/dependency_links.txt +0 -0
- {wnox-0.8.0 → wnox-1.0.0}/wnox.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: wnox
|
3
|
-
Version: 0.
|
3
|
+
Version: 1.0.0
|
4
4
|
Summary: QE nexus client.
|
5
5
|
Home-page: https://github.com/arminkardan/pywnox
|
6
6
|
Author: Ethan (Armin) Cardan
|
@@ -13,7 +13,8 @@ Requires-Python: >=3.11
|
|
13
13
|
Description-Content-Type: text/markdown
|
14
14
|
License-File: LICENSE.txt
|
15
15
|
Requires-Dist: slixmpp
|
16
|
-
Requires-Dist:
|
16
|
+
Requires-Dist: python-dotenv
|
17
|
+
Requires-Dist: pymongo
|
17
18
|
Dynamic: author
|
18
19
|
Dynamic: home-page
|
19
20
|
Dynamic: requires-python
|
@@ -4,12 +4,12 @@ build-backend = "setuptools.build_meta"
|
|
4
4
|
|
5
5
|
[project]
|
6
6
|
name = "wnox"
|
7
|
-
version = "0.
|
7
|
+
version = "1.0.0"
|
8
8
|
authors = [{ name = "Ethan (Armin) Cardan", email = "armin.fire@gmail.com" }]
|
9
9
|
description = "QE nexus client."
|
10
10
|
readme = "README.md"
|
11
11
|
license = { file = "LICENSE" }
|
12
|
-
dependencies = ["slixmpp","
|
12
|
+
dependencies = ["slixmpp","python-dotenv","pymongo"]
|
13
13
|
requires-python = ">=3.11"
|
14
14
|
classifiers = [
|
15
15
|
"Programming Language :: Python :: 3",
|
@@ -10,6 +10,10 @@ import requests as r
|
|
10
10
|
|
11
11
|
import random
|
12
12
|
import string
|
13
|
+
from dotenv import load_dotenv
|
14
|
+
import os
|
15
|
+
from pymongo import MongoClient
|
16
|
+
|
13
17
|
|
14
18
|
nest_asyncio.apply()
|
15
19
|
eventdatax = {}
|
@@ -46,6 +50,11 @@ class WSX(ClientXMPP, EventEmitter):
|
|
46
50
|
connected = False
|
47
51
|
def __init__(self, jid, password, app:str, uid:str, resource:str):
|
48
52
|
|
53
|
+
if "-" in app:
|
54
|
+
raise "app should not contain dash '-'"
|
55
|
+
if "-" in resource:
|
56
|
+
raise "resource should not contain dash '-'"
|
57
|
+
|
49
58
|
ClientXMPP.__init__(self, jid, password)
|
50
59
|
EventEmitter.__init__(self)
|
51
60
|
self.app = app
|
@@ -59,7 +68,7 @@ class WSX(ClientXMPP, EventEmitter):
|
|
59
68
|
|
60
69
|
async def start(self, event):
|
61
70
|
"""Handle session start."""
|
62
|
-
|
71
|
+
|
63
72
|
self.send_presence(ptype="presence")
|
64
73
|
await self.get_roster()
|
65
74
|
await self.emit("__connect",{})
|
@@ -113,16 +122,14 @@ class WSX(ClientXMPP, EventEmitter):
|
|
113
122
|
data = {key: val for key, val in data.items() if key != "mid"}
|
114
123
|
data["from"] = from_jid
|
115
124
|
data["app"] = None
|
125
|
+
|
116
126
|
if len(user_uid) == 24 and ObjectId.is_valid(user_uid):
|
117
127
|
data["uid"] = user_uid
|
118
128
|
data["app"] = None
|
119
|
-
|
120
|
-
if
|
121
|
-
|
122
|
-
|
123
|
-
mto=from_jid,
|
124
|
-
mbody=json.dumps({**result, "mid": json_data.get("mid")})
|
125
|
-
)
|
129
|
+
data["resource"] = None
|
130
|
+
if "@qepal.com/" in from_jid:
|
131
|
+
data["resource"] = from_jid.split("@qepal.com/")[1]
|
132
|
+
|
126
133
|
elif "conference.qepal.com" in from_jid:
|
127
134
|
pass
|
128
135
|
elif "-" in user_uid:
|
@@ -130,6 +137,15 @@ class WSX(ClientXMPP, EventEmitter):
|
|
130
137
|
user_uid = user_uid.split('-')[1]
|
131
138
|
data["app"] = app
|
132
139
|
data["uid"] = user_uid
|
140
|
+
data["resource"] = from_jid.split('@qepal.com/')[1]
|
141
|
+
|
142
|
+
result = await self.emit(json_data["api"], data)
|
143
|
+
if result == None:
|
144
|
+
result = {}
|
145
|
+
self.send_message(
|
146
|
+
mto=from_jid,
|
147
|
+
mbody=json.dumps({**result, "mid": json_data.get("mid")})
|
148
|
+
)
|
133
149
|
|
134
150
|
else:
|
135
151
|
if "mid" in json_data:
|
@@ -138,18 +154,80 @@ class WSX(ClientXMPP, EventEmitter):
|
|
138
154
|
if json_data.get("mid") in eventsx:
|
139
155
|
eventsx.get(json_data.get("mid")).set()
|
140
156
|
else:
|
141
|
-
|
157
|
+
|
158
|
+
data["channel"] = None
|
159
|
+
if "@conference.qepal.com" in from_jid:
|
160
|
+
s = from_jid.split("@conference.qepal.com/")
|
161
|
+
data = {"from": from_jid, "body": body, "itsme": itsme, "itsbro": itsbro}
|
162
|
+
data["channel"] = s[0]
|
163
|
+
data["uid"] = None
|
164
|
+
data["resource"] = None
|
165
|
+
data["app"] = None
|
166
|
+
ss = s[1].split("-")
|
167
|
+
if len(ss) == 2 and len(ss[0]) == 24 and ObjectId.is_valid(ss[0]):
|
168
|
+
data["uid"] = ss[0]
|
169
|
+
data["resource"] = ss[1]
|
170
|
+
elif len(ss) == 3 and len(ss[1]) == 24 and ObjectId.is_valid(ss[1]):
|
171
|
+
data["uid"] = ss[1]
|
172
|
+
data["app"] = ss[0]
|
173
|
+
data["resource"] = ss[2]
|
174
|
+
await self.emit("__message", data)
|
142
175
|
|
143
176
|
except json.JSONDecodeError:
|
144
177
|
pass
|
145
178
|
else:
|
146
|
-
|
147
|
-
|
179
|
+
data = {"from": from_jid, "body": body, "itsme": itsme, "itsbro": itsbro}
|
180
|
+
data["channel"] = None
|
181
|
+
data["uid"] = None
|
182
|
+
data["resource"] = None
|
183
|
+
data["app"] = None
|
184
|
+
if "@qepal.com" in from_jid:
|
185
|
+
ss = from_jid.split("@qepal.com/")
|
186
|
+
if len(ss) == 2 and len(ss[0]) == 24 and ObjectId.is_valid(ss[0]):
|
187
|
+
data["uid"] = ss[0]
|
188
|
+
data["resource"] = ss[1]
|
189
|
+
elif "-" in ss[0]:
|
190
|
+
sss = ss[0].split("-")
|
191
|
+
data["app"] = sss[0]
|
192
|
+
data["uid"] = sss[1]
|
193
|
+
data["resource"] = ss[1]
|
194
|
+
elif "@conference.qepal.com" in from_jid:
|
195
|
+
ss = from_jid.split("@conference.qepal.com/")
|
196
|
+
data["channel"] = ss[0]
|
197
|
+
if "-" in ss[1]:
|
198
|
+
sss = ss[1].split("-")
|
199
|
+
if len(sss) == 2:
|
200
|
+
data["uid"] = sss[0]
|
201
|
+
data["resource"] = sss[1]
|
202
|
+
elif len(sss) == 3 and len(sss[1]) == 24 and ObjectId.is_valid(sss[1]):
|
203
|
+
data["app"] = sss[0]
|
204
|
+
data["uid"] = sss[1]
|
205
|
+
data["resource"] = sss[2]
|
206
|
+
await self.emit("__message",data)
|
207
|
+
|
148
208
|
|
149
209
|
|
150
210
|
class App:
|
151
211
|
|
212
|
+
udb = None
|
152
213
|
def __init__(self, *, app:str, resource:str, securekey:str, image:str, public:bool=False):
|
214
|
+
|
215
|
+
load_dotenv(".env.local")
|
216
|
+
mongourl = os.getenv("UMONGOURL")
|
217
|
+
mongo_db = os.getenv("UMONGODB_DB")
|
218
|
+
|
219
|
+
if mongourl:
|
220
|
+
try:
|
221
|
+
client = MongoClient(mongourl)
|
222
|
+
client.server_info()
|
223
|
+
self.udb = client[mongo_db]
|
224
|
+
print("✅ mongo udb connected.")
|
225
|
+
except:
|
226
|
+
print("❌ mongo udb not connected.")
|
227
|
+
else:
|
228
|
+
print("❌ no .env.local correct file")
|
229
|
+
|
230
|
+
|
153
231
|
self.app = app
|
154
232
|
self.channels = set()
|
155
233
|
self.resource = resource
|
@@ -184,8 +262,7 @@ class App:
|
|
184
262
|
else:
|
185
263
|
jid = jids[0]
|
186
264
|
if jid == None:
|
187
|
-
|
188
|
-
return
|
265
|
+
return { "error": "no worker found" }
|
189
266
|
|
190
267
|
mid = serial_generator(10)
|
191
268
|
msg = {"mid":mid, "api":cmd, **body }
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: wnox
|
3
|
-
Version: 0.
|
3
|
+
Version: 1.0.0
|
4
4
|
Summary: QE nexus client.
|
5
5
|
Home-page: https://github.com/arminkardan/pywnox
|
6
6
|
Author: Ethan (Armin) Cardan
|
@@ -13,7 +13,8 @@ Requires-Python: >=3.11
|
|
13
13
|
Description-Content-Type: text/markdown
|
14
14
|
License-File: LICENSE.txt
|
15
15
|
Requires-Dist: slixmpp
|
16
|
-
Requires-Dist:
|
16
|
+
Requires-Dist: python-dotenv
|
17
|
+
Requires-Dist: pymongo
|
17
18
|
Dynamic: author
|
18
19
|
Dynamic: home-page
|
19
20
|
Dynamic: requires-python
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|