webex-bot 0.6.2__tar.gz → 1.0.1__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.
- {webex_bot-0.6.2/webex_bot.egg-info → webex_bot-1.0.1}/PKG-INFO +5 -1
- {webex_bot-0.6.2 → webex_bot-1.0.1}/README.md +4 -0
- {webex_bot-0.6.2 → webex_bot-1.0.1}/setup.cfg +1 -1
- {webex_bot-0.6.2 → webex_bot-1.0.1}/setup.py +1 -1
- {webex_bot-0.6.2 → webex_bot-1.0.1}/webex_bot/__init__.py +1 -1
- {webex_bot-0.6.2 → webex_bot-1.0.1}/webex_bot/websockets/webex_websocket_client.py +26 -17
- {webex_bot-0.6.2 → webex_bot-1.0.1/webex_bot.egg-info}/PKG-INFO +5 -1
- {webex_bot-0.6.2 → webex_bot-1.0.1}/CONTRIBUTING.rst +0 -0
- {webex_bot-0.6.2 → webex_bot-1.0.1}/LICENSE +0 -0
- {webex_bot-0.6.2 → webex_bot-1.0.1}/MANIFEST.in +0 -0
- {webex_bot-0.6.2 → webex_bot-1.0.1}/docs/Makefile +0 -0
- {webex_bot-0.6.2 → webex_bot-1.0.1}/docs/conf.py +0 -0
- {webex_bot-0.6.2 → webex_bot-1.0.1}/docs/contributing.rst +0 -0
- {webex_bot-0.6.2 → webex_bot-1.0.1}/docs/index.rst +0 -0
- {webex_bot-0.6.2 → webex_bot-1.0.1}/docs/installation.rst +0 -0
- {webex_bot-0.6.2 → webex_bot-1.0.1}/docs/make.bat +0 -0
- {webex_bot-0.6.2 → webex_bot-1.0.1}/docs/usage.rst +0 -0
- {webex_bot-0.6.2 → webex_bot-1.0.1}/tests/__init__.py +0 -0
- {webex_bot-0.6.2 → webex_bot-1.0.1}/tests/test_webex_bot.py +0 -0
- {webex_bot-0.6.2 → webex_bot-1.0.1}/webex_bot/cards/__init__.py +0 -0
- {webex_bot-0.6.2 → webex_bot-1.0.1}/webex_bot/commands/__init__.py +0 -0
- {webex_bot-0.6.2 → webex_bot-1.0.1}/webex_bot/commands/echo.py +0 -0
- {webex_bot-0.6.2 → webex_bot-1.0.1}/webex_bot/commands/help.py +0 -0
- {webex_bot-0.6.2 → webex_bot-1.0.1}/webex_bot/exceptions.py +0 -0
- {webex_bot-0.6.2 → webex_bot-1.0.1}/webex_bot/formatting.py +0 -0
- {webex_bot-0.6.2 → webex_bot-1.0.1}/webex_bot/models/__init__.py +0 -0
- {webex_bot-0.6.2 → webex_bot-1.0.1}/webex_bot/models/command.py +0 -0
- {webex_bot-0.6.2 → webex_bot-1.0.1}/webex_bot/models/response.py +0 -0
- {webex_bot-0.6.2 → webex_bot-1.0.1}/webex_bot/webex_bot.py +0 -0
- {webex_bot-0.6.2 → webex_bot-1.0.1}/webex_bot/websockets/__init__.py +0 -0
- {webex_bot-0.6.2 → webex_bot-1.0.1}/webex_bot.egg-info/SOURCES.txt +0 -0
- {webex_bot-0.6.2 → webex_bot-1.0.1}/webex_bot.egg-info/dependency_links.txt +0 -0
- {webex_bot-0.6.2 → webex_bot-1.0.1}/webex_bot.egg-info/not-zip-safe +0 -0
- {webex_bot-0.6.2 → webex_bot-1.0.1}/webex_bot.egg-info/requires.txt +0 -0
- {webex_bot-0.6.2 → webex_bot-1.0.1}/webex_bot.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: webex_bot
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 1.0.1
|
|
4
4
|
Summary: Python package for a Webex Bot based on websockets.
|
|
5
5
|
Home-page: https://github.com/fbradyirl/webex_bot
|
|
6
6
|
Author: Finbarr Brady
|
|
@@ -447,6 +447,10 @@ bot = WebexBot(teams_bot_token=os.getenv("WEBEX_ACCESS_TOKEN")
|
|
|
447
447
|
|
|
448
448
|
* Fix for [issue #48][i48] - Fix for `Commands not being received` issue.
|
|
449
449
|
|
|
450
|
+
### 1.0.1 (2025-Jun-04)
|
|
451
|
+
|
|
452
|
+
* Add connection headers to requests.
|
|
453
|
+
|
|
450
454
|
[1]: https://github.com/aaugustin/websockets
|
|
451
455
|
|
|
452
456
|
[2]: https://github.com/WebexCommunity/WebexPythonSDK
|
|
@@ -407,6 +407,10 @@ bot = WebexBot(teams_bot_token=os.getenv("WEBEX_ACCESS_TOKEN")
|
|
|
407
407
|
|
|
408
408
|
* Fix for [issue #48][i48] - Fix for `Commands not being received` issue.
|
|
409
409
|
|
|
410
|
+
### 1.0.1 (2025-Jun-04)
|
|
411
|
+
|
|
412
|
+
* Add connection headers to requests.
|
|
413
|
+
|
|
410
414
|
[1]: https://github.com/aaugustin/websockets
|
|
411
415
|
|
|
412
416
|
[2]: https://github.com/WebexCommunity/WebexPythonSDK
|
|
@@ -12,6 +12,8 @@ import websockets
|
|
|
12
12
|
from webexpythonsdk import WebexAPI
|
|
13
13
|
from websockets.exceptions import InvalidStatusCode
|
|
14
14
|
|
|
15
|
+
from webex_bot import __version__
|
|
16
|
+
|
|
15
17
|
try:
|
|
16
18
|
from websockets_proxy import Proxy, proxy_connect
|
|
17
19
|
except ImportError:
|
|
@@ -46,6 +48,11 @@ class WebexWebsocketClient(object):
|
|
|
46
48
|
proxies=None):
|
|
47
49
|
self.access_token = access_token
|
|
48
50
|
self.teams = WebexAPI(access_token=access_token, proxies=proxies)
|
|
51
|
+
self.tracking_id = f"webex-bot_{uuid.uuid4()}"
|
|
52
|
+
self.session = requests.Session()
|
|
53
|
+
self.session.headers = self._get_headers()
|
|
54
|
+
# log the tracking ID
|
|
55
|
+
logger.info(f"Tracking ID: {self.tracking_id}")
|
|
49
56
|
self.device_info = None
|
|
50
57
|
self.device_url = self._get_device_url()
|
|
51
58
|
self.on_message = on_message
|
|
@@ -53,12 +60,20 @@ class WebexWebsocketClient(object):
|
|
|
53
60
|
self.proxies = proxies
|
|
54
61
|
self.websocket = None
|
|
55
62
|
self.share_id = None
|
|
56
|
-
|
|
63
|
+
if self.proxies:
|
|
64
|
+
self.session.proxies = proxies
|
|
57
65
|
if self.proxies:
|
|
58
66
|
# Connecting through a proxy
|
|
59
67
|
if proxy_connect is None:
|
|
60
68
|
raise ImportError("Failed to load libraries for proxy, maybe forgot [proxy] option during installation.")
|
|
61
69
|
|
|
70
|
+
def _get_headers(self):
|
|
71
|
+
return {
|
|
72
|
+
"Authorization": f"Bearer {self.access_token}",
|
|
73
|
+
"User-Agent": f"webex_bot/{__version__}",
|
|
74
|
+
"trackingid": self.tracking_id
|
|
75
|
+
}
|
|
76
|
+
|
|
62
77
|
def _process_incoming_websocket_message(self, msg):
|
|
63
78
|
"""
|
|
64
79
|
Handle websocket data.
|
|
@@ -135,10 +150,7 @@ class WebexWebsocketClient(object):
|
|
|
135
150
|
logger.debug(f"activity_id={activity_id}")
|
|
136
151
|
conversation_message_url = conversation_url.replace(f"conversations/{conv_target_id}",
|
|
137
152
|
f"{verb}/{activity_id}")
|
|
138
|
-
|
|
139
|
-
conversation_message = requests.get(conversation_message_url,
|
|
140
|
-
headers=headers,
|
|
141
|
-
proxies=self.proxies).json()
|
|
153
|
+
conversation_message = self.session.get(conversation_message_url).json()
|
|
142
154
|
logger.debug(f"conversation_message={conversation_message}")
|
|
143
155
|
return conversation_message['id']
|
|
144
156
|
|
|
@@ -155,11 +167,8 @@ class WebexWebsocketClient(object):
|
|
|
155
167
|
logger.info(f"WebSocket ack message with id={message_id}. Complete.")
|
|
156
168
|
|
|
157
169
|
def _get_device_url(self):
|
|
158
|
-
headers = {}
|
|
159
|
-
headers["Authorization"] = 'Bearer ' + self.access_token
|
|
160
|
-
|
|
161
170
|
params = {"format": "hostmap"}
|
|
162
|
-
response =
|
|
171
|
+
response = self.session.get(DEFAULT_U2C_URL, params=params)
|
|
163
172
|
|
|
164
173
|
# check for 401 Unauthorized
|
|
165
174
|
if response.status_code == 401:
|
|
@@ -182,8 +191,8 @@ class WebexWebsocketClient(object):
|
|
|
182
191
|
if check_existing:
|
|
183
192
|
logger.debug('Getting device list')
|
|
184
193
|
try:
|
|
185
|
-
resp = self.
|
|
186
|
-
for device in resp['devices']:
|
|
194
|
+
resp = self.session.get(f"{self.device_url}/devices")
|
|
195
|
+
for device in resp.json()['devices']:
|
|
187
196
|
if device['name'] == DEVICE_DATA['name']:
|
|
188
197
|
self.device_info = device
|
|
189
198
|
logger.debug(f"device_info: {self.device_info}")
|
|
@@ -193,12 +202,12 @@ class WebexWebsocketClient(object):
|
|
|
193
202
|
|
|
194
203
|
logger.info('Device does not exist, creating')
|
|
195
204
|
|
|
196
|
-
resp = self.
|
|
205
|
+
resp = self.session.post(f"{self.device_url}/devices", json=DEVICE_DATA)
|
|
197
206
|
if resp is None:
|
|
198
207
|
raise Exception("could not create WDM device")
|
|
199
|
-
self.device_info = resp
|
|
208
|
+
self.device_info = resp.json()
|
|
200
209
|
logger.debug(f"self.device_info: {self.device_info}")
|
|
201
|
-
return
|
|
210
|
+
return self.device_info
|
|
202
211
|
|
|
203
212
|
def stop(self):
|
|
204
213
|
def terminate():
|
|
@@ -244,14 +253,14 @@ class WebexWebsocketClient(object):
|
|
|
244
253
|
if self.proxies and "wss" in self.proxies:
|
|
245
254
|
logger.info(f"Using proxy for websocket connection: {self.proxies['wss']}")
|
|
246
255
|
proxy = Proxy.from_url(self.proxies["wss"])
|
|
247
|
-
connect = proxy_connect(ws_url, ssl=ssl_context, proxy=proxy)
|
|
256
|
+
connect = proxy_connect(ws_url, ssl=ssl_context, proxy=proxy, extra_headers=self._get_headers())
|
|
248
257
|
elif self.proxies and "https" in self.proxies:
|
|
249
258
|
logger.info(f"Using proxy for websocket connection: {self.proxies['https']}")
|
|
250
259
|
proxy = Proxy.from_url(self.proxies["https"])
|
|
251
|
-
connect = proxy_connect(ws_url, ssl=ssl_context, proxy=proxy)
|
|
260
|
+
connect = proxy_connect(ws_url, ssl=ssl_context, proxy=proxy, extra_headers=self._get_headers())
|
|
252
261
|
else:
|
|
253
262
|
logger.debug(f"Not using proxy for websocket connection.")
|
|
254
|
-
connect = websockets.connect(ws_url, ssl=ssl_context)
|
|
263
|
+
connect = websockets.connect(ws_url, ssl=ssl_context, extra_headers=self._get_headers())
|
|
255
264
|
|
|
256
265
|
async with connect as _websocket:
|
|
257
266
|
self.websocket = _websocket
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: webex_bot
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 1.0.1
|
|
4
4
|
Summary: Python package for a Webex Bot based on websockets.
|
|
5
5
|
Home-page: https://github.com/fbradyirl/webex_bot
|
|
6
6
|
Author: Finbarr Brady
|
|
@@ -447,6 +447,10 @@ bot = WebexBot(teams_bot_token=os.getenv("WEBEX_ACCESS_TOKEN")
|
|
|
447
447
|
|
|
448
448
|
* Fix for [issue #48][i48] - Fix for `Commands not being received` issue.
|
|
449
449
|
|
|
450
|
+
### 1.0.1 (2025-Jun-04)
|
|
451
|
+
|
|
452
|
+
* Add connection headers to requests.
|
|
453
|
+
|
|
450
454
|
[1]: https://github.com/aaugustin/websockets
|
|
451
455
|
|
|
452
456
|
[2]: https://github.com/WebexCommunity/WebexPythonSDK
|
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|