webex-bot 0.5.0__tar.gz → 0.5.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.
Files changed (35) hide show
  1. {webex_bot-0.5.0 → webex_bot-0.5.1}/PKG-INFO +35 -7
  2. {webex_bot-0.5.0 → webex_bot-0.5.1}/README.md +33 -6
  3. {webex_bot-0.5.0 → webex_bot-0.5.1}/setup.cfg +1 -1
  4. {webex_bot-0.5.0 → webex_bot-0.5.1}/setup.py +6 -1
  5. {webex_bot-0.5.0 → webex_bot-0.5.1}/webex_bot/__init__.py +1 -1
  6. {webex_bot-0.5.0 → webex_bot-0.5.1}/webex_bot/webex_bot.py +5 -3
  7. {webex_bot-0.5.0 → webex_bot-0.5.1}/webex_bot/websockets/webex_websocket_client.py +32 -5
  8. {webex_bot-0.5.0 → webex_bot-0.5.1}/webex_bot.egg-info/PKG-INFO +35 -7
  9. {webex_bot-0.5.0 → webex_bot-0.5.1}/webex_bot.egg-info/requires.txt +3 -0
  10. {webex_bot-0.5.0 → webex_bot-0.5.1}/CONTRIBUTING.rst +0 -0
  11. {webex_bot-0.5.0 → webex_bot-0.5.1}/LICENSE +0 -0
  12. {webex_bot-0.5.0 → webex_bot-0.5.1}/MANIFEST.in +0 -0
  13. {webex_bot-0.5.0 → webex_bot-0.5.1}/docs/Makefile +0 -0
  14. {webex_bot-0.5.0 → webex_bot-0.5.1}/docs/conf.py +0 -0
  15. {webex_bot-0.5.0 → webex_bot-0.5.1}/docs/contributing.rst +0 -0
  16. {webex_bot-0.5.0 → webex_bot-0.5.1}/docs/index.rst +0 -0
  17. {webex_bot-0.5.0 → webex_bot-0.5.1}/docs/installation.rst +0 -0
  18. {webex_bot-0.5.0 → webex_bot-0.5.1}/docs/make.bat +0 -0
  19. {webex_bot-0.5.0 → webex_bot-0.5.1}/docs/usage.rst +0 -0
  20. {webex_bot-0.5.0 → webex_bot-0.5.1}/tests/__init__.py +0 -0
  21. {webex_bot-0.5.0 → webex_bot-0.5.1}/tests/test_webex_bot.py +0 -0
  22. {webex_bot-0.5.0 → webex_bot-0.5.1}/webex_bot/cards/__init__.py +0 -0
  23. {webex_bot-0.5.0 → webex_bot-0.5.1}/webex_bot/commands/__init__.py +0 -0
  24. {webex_bot-0.5.0 → webex_bot-0.5.1}/webex_bot/commands/echo.py +0 -0
  25. {webex_bot-0.5.0 → webex_bot-0.5.1}/webex_bot/commands/help.py +0 -0
  26. {webex_bot-0.5.0 → webex_bot-0.5.1}/webex_bot/exceptions.py +0 -0
  27. {webex_bot-0.5.0 → webex_bot-0.5.1}/webex_bot/formatting.py +0 -0
  28. {webex_bot-0.5.0 → webex_bot-0.5.1}/webex_bot/models/__init__.py +0 -0
  29. {webex_bot-0.5.0 → webex_bot-0.5.1}/webex_bot/models/command.py +0 -0
  30. {webex_bot-0.5.0 → webex_bot-0.5.1}/webex_bot/models/response.py +0 -0
  31. {webex_bot-0.5.0 → webex_bot-0.5.1}/webex_bot/websockets/__init__.py +0 -0
  32. {webex_bot-0.5.0 → webex_bot-0.5.1}/webex_bot.egg-info/SOURCES.txt +0 -0
  33. {webex_bot-0.5.0 → webex_bot-0.5.1}/webex_bot.egg-info/dependency_links.txt +0 -0
  34. {webex_bot-0.5.0 → webex_bot-0.5.1}/webex_bot.egg-info/not-zip-safe +0 -0
  35. {webex_bot-0.5.0 → webex_bot-0.5.1}/webex_bot.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: webex_bot
3
- Version: 0.5.0
3
+ Version: 0.5.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
@@ -16,6 +16,7 @@ Classifier: Programming Language :: Python :: 3.8
16
16
  Classifier: Programming Language :: Python :: 3.9
17
17
  Requires-Python: >=3.8
18
18
  Description-Content-Type: text/markdown
19
+ Provides-Extra: proxy
19
20
  License-File: LICENSE
20
21
 
21
22
  # Introduction
@@ -53,6 +54,10 @@ You can find a sample project, using OpenAI/ChatGPT with this library here: http
53
54
 
54
55
  `pip install webex_bot`
55
56
 
57
+ If you need optional proxy support, use this command instead:
58
+
59
+ `pip install webex_bot[proxy]`
60
+
56
61
  2. On the Webex Developer portal, create a new [bot token][3] and expose it as an environment variable.
57
62
 
58
63
  ```sh
@@ -71,11 +76,19 @@ import os
71
76
  from webex_bot.commands.echo import EchoCommand
72
77
  from webex_bot.webex_bot import WebexBot
73
78
 
79
+ # (Optional) Proxy configuration
80
+ # Supports https or wss proxy, wss prioritized.
81
+ proxies = {
82
+ 'https': 'http://proxy.esl.example.com:80',
83
+ 'wss': 'socks5://proxy.esl.example.com:1080'
84
+ }
85
+
74
86
  # Create a Bot Object
75
87
  bot = WebexBot(teams_bot_token=os.getenv("WEBEX_TEAMS_ACCESS_TOKEN"),
76
88
  approved_rooms=['06586d8d-6aad-4201-9a69-0bf9eeb5766e'],
77
89
  bot_name="My Teams Ops Bot",
78
- include_demo_commands=True)
90
+ include_demo_commands=True,
91
+ proxies=proxies)
79
92
 
80
93
  # Add new commands for the bot to listen out for.
81
94
  bot.add_command(EchoCommand())
@@ -353,13 +366,16 @@ and off you go!
353
366
 
354
367
  ### 0.5.0 (2024-Apr-25)
355
368
 
356
- * Add max backoff time (#55)
357
- * Attached files. Help, threading and log level overrides. (#54)
358
- * add stop() call to gracefully exit the bot (#42)
359
- * feat(20231212): add help image size parameter (#46)
360
- * update websockets to 11.0.3 (#43)
369
+ * Add max backoff time ([#55][pr55])
370
+ * Attached files. Help, threading and log level overrides. ([#54][pr54])
371
+ * add stop() call to gracefully exit the bot ([#42][pr42])
372
+ * feat(20231212): add help image size parameter ([#46][pr46])
373
+ * update websockets to 11.0.3 ([#43][pr43])
361
374
  * Fix for help_command syntax issue
362
375
 
376
+ ### 0.5.1 (2024-Apr-25)
377
+
378
+ * Add Proxy Support. ([#56][pr56])
363
379
 
364
380
  [1]: https://github.com/aaugustin/websockets
365
381
 
@@ -375,6 +391,18 @@ and off you go!
375
391
 
376
392
  [7]: https://eurl.io/#TeBLqZjLs
377
393
 
394
+ [pr43]: https://github.com/fbradyirl/webex_bot/pull/43
395
+
396
+ [pr46]: https://github.com/fbradyirl/webex_bot/pull/46
397
+
398
+ [pr42]: https://github.com/fbradyirl/webex_bot/pull/42
399
+
400
+ [pr54]: https://github.com/fbradyirl/webex_bot/pull/54
401
+
402
+ [pr55]: https://github.com/fbradyirl/webex_bot/pull/55
403
+
404
+ [pr56]: https://github.com/fbradyirl/webex_bot/pull/56
405
+
378
406
  [i1]: https://github.com/fbradyirl/webex_bot/issues/1
379
407
 
380
408
  [i2]: https://github.com/fbradyirl/webex_bot/issues/2
@@ -33,6 +33,10 @@ You can find a sample project, using OpenAI/ChatGPT with this library here: http
33
33
 
34
34
  `pip install webex_bot`
35
35
 
36
+ If you need optional proxy support, use this command instead:
37
+
38
+ `pip install webex_bot[proxy]`
39
+
36
40
  2. On the Webex Developer portal, create a new [bot token][3] and expose it as an environment variable.
37
41
 
38
42
  ```sh
@@ -51,11 +55,19 @@ import os
51
55
  from webex_bot.commands.echo import EchoCommand
52
56
  from webex_bot.webex_bot import WebexBot
53
57
 
58
+ # (Optional) Proxy configuration
59
+ # Supports https or wss proxy, wss prioritized.
60
+ proxies = {
61
+ 'https': 'http://proxy.esl.example.com:80',
62
+ 'wss': 'socks5://proxy.esl.example.com:1080'
63
+ }
64
+
54
65
  # Create a Bot Object
55
66
  bot = WebexBot(teams_bot_token=os.getenv("WEBEX_TEAMS_ACCESS_TOKEN"),
56
67
  approved_rooms=['06586d8d-6aad-4201-9a69-0bf9eeb5766e'],
57
68
  bot_name="My Teams Ops Bot",
58
- include_demo_commands=True)
69
+ include_demo_commands=True,
70
+ proxies=proxies)
59
71
 
60
72
  # Add new commands for the bot to listen out for.
61
73
  bot.add_command(EchoCommand())
@@ -333,13 +345,16 @@ and off you go!
333
345
 
334
346
  ### 0.5.0 (2024-Apr-25)
335
347
 
336
- * Add max backoff time (#55)
337
- * Attached files. Help, threading and log level overrides. (#54)
338
- * add stop() call to gracefully exit the bot (#42)
339
- * feat(20231212): add help image size parameter (#46)
340
- * update websockets to 11.0.3 (#43)
348
+ * Add max backoff time ([#55][pr55])
349
+ * Attached files. Help, threading and log level overrides. ([#54][pr54])
350
+ * add stop() call to gracefully exit the bot ([#42][pr42])
351
+ * feat(20231212): add help image size parameter ([#46][pr46])
352
+ * update websockets to 11.0.3 ([#43][pr43])
341
353
  * Fix for help_command syntax issue
342
354
 
355
+ ### 0.5.1 (2024-Apr-25)
356
+
357
+ * Add Proxy Support. ([#56][pr56])
343
358
 
344
359
  [1]: https://github.com/aaugustin/websockets
345
360
 
@@ -355,6 +370,18 @@ and off you go!
355
370
 
356
371
  [7]: https://eurl.io/#TeBLqZjLs
357
372
 
373
+ [pr43]: https://github.com/fbradyirl/webex_bot/pull/43
374
+
375
+ [pr46]: https://github.com/fbradyirl/webex_bot/pull/46
376
+
377
+ [pr42]: https://github.com/fbradyirl/webex_bot/pull/42
378
+
379
+ [pr54]: https://github.com/fbradyirl/webex_bot/pull/54
380
+
381
+ [pr55]: https://github.com/fbradyirl/webex_bot/pull/55
382
+
383
+ [pr56]: https://github.com/fbradyirl/webex_bot/pull/56
384
+
358
385
  [i1]: https://github.com/fbradyirl/webex_bot/issues/1
359
386
 
360
387
  [i2]: https://github.com/fbradyirl/webex_bot/issues/2
@@ -1,5 +1,5 @@
1
1
  [bumpversion]
2
- current_version = 0.5.0
2
+ current_version = 0.5.1
3
3
  commit = True
4
4
  tag = True
5
5
 
@@ -13,6 +13,10 @@ setup_requirements = ['pytest-runner', ]
13
13
 
14
14
  test_requirements = ['pytest>=3', ]
15
15
 
16
+ extras_requirements = {
17
+ "proxy": ["websockets_proxy>=0.1.1"]
18
+ }
19
+
16
20
  setup(
17
21
  author="Finbarr Brady",
18
22
  author_email='finbarr@somemail.com',
@@ -26,6 +30,7 @@ setup(
26
30
  'Programming Language :: Python :: 3.9',
27
31
  ],
28
32
  description="Python package for a Webex Bot based on websockets.",
33
+ extras_require=extras_requirements,
29
34
  install_requires=requirements,
30
35
  license="MIT license",
31
36
  long_description=readme,
@@ -38,6 +43,6 @@ setup(
38
43
  test_suite='tests',
39
44
  tests_require=test_requirements,
40
45
  url='https://github.com/fbradyirl/webex_bot',
41
- version='0.5.0',
46
+ version='0.5.1',
42
47
  zip_safe=False,
43
48
  )
@@ -1,4 +1,4 @@
1
1
  """Top-level package for Webex Bot."""
2
2
 
3
3
  __author__ = """Finbarr Brady"""
4
- __version__ = '0.5.0'
4
+ __version__ = '0.5.1'
@@ -31,7 +31,8 @@ class WebexBot(WebexWebsocketClient):
31
31
  bot_help_subtitle="Here are my available commands. Click one to begin.",
32
32
  threads=True,
33
33
  help_command=None,
34
- log_level="INFO"):
34
+ log_level="INFO",
35
+ proxies=None):
35
36
  """
36
37
  Initialise WebexBot.
37
38
 
@@ -46,7 +47,7 @@ class WebexBot(WebexWebsocketClient):
46
47
  @param threads: If True, respond to msg by creating a thread.
47
48
  @param help_command: If None, use internal HelpCommand, otherwise override.
48
49
  @param log_level: Set loggin level.
49
-
50
+ @param proxies: Dictionary of proxies for connections.
50
51
  """
51
52
 
52
53
  coloredlogs.install(level=os.getenv("LOG_LEVEL", log_level),
@@ -58,7 +59,8 @@ class WebexBot(WebexWebsocketClient):
58
59
  teams_bot_token,
59
60
  on_message=self.process_incoming_message,
60
61
  on_card_action=self.process_incoming_card_action,
61
- device_url=device_url)
62
+ device_url=device_url,
63
+ proxies=proxies)
62
64
 
63
65
  if help_command is None:
64
66
  self.help_command = HelpCommand(
@@ -11,6 +11,12 @@ import requests
11
11
  import websockets
12
12
  from webexteamssdk import WebexTeamsAPI
13
13
 
14
+ try:
15
+ from websockets_proxy import Proxy, proxy_connect
16
+ except ImportError:
17
+ Proxy = None
18
+ proxy_connect = None
19
+
14
20
  logger = logging.getLogger(__name__)
15
21
 
16
22
  DEFAULT_DEVICE_URL = "https://wdm-a.wbx2.com/wdm/api/v1"
@@ -36,16 +42,23 @@ class WebexWebsocketClient(object):
36
42
  access_token,
37
43
  device_url=DEFAULT_DEVICE_URL,
38
44
  on_message=None,
39
- on_card_action=None):
45
+ on_card_action=None,
46
+ proxies=None):
40
47
  self.access_token = access_token
41
- self.teams = WebexTeamsAPI(access_token=access_token)
48
+ self.teams = WebexTeamsAPI(access_token=access_token, proxies=proxies)
42
49
  self.device_url = device_url
43
50
  self.device_info = None
44
51
  self.on_message = on_message
45
52
  self.on_card_action = on_card_action
53
+ self.proxies = proxies
46
54
  self.websocket = None
47
55
  self.share_id = None
48
56
 
57
+ if self.proxies:
58
+ # Connecting through a proxy
59
+ if proxy_connect is None:
60
+ raise ImportError("Failed to load libraries for proxy, maybe forgot [proxy] option during installation.")
61
+
49
62
  def _process_incoming_websocket_message(self, msg):
50
63
  """
51
64
  Handle websocket data.
@@ -124,7 +137,8 @@ class WebexWebsocketClient(object):
124
137
  f"{verb}/{activity_id}")
125
138
  headers = {"Authorization": f"Bearer {self.access_token}"}
126
139
  conversation_message = requests.get(conversation_message_url,
127
- headers=headers).json()
140
+ headers=headers,
141
+ proxies=self.proxies).json()
128
142
  logger.debug(f"conversation_message={conversation_message}")
129
143
  return conversation_message['id']
130
144
 
@@ -197,7 +211,20 @@ class WebexWebsocketClient(object):
197
211
  async def _connect_and_listen():
198
212
  ws_url = self.device_info['webSocketUrl']
199
213
  logger.info(f"Opening websocket connection to {ws_url}")
200
- async with websockets.connect(ws_url, ssl=ssl_context) as _websocket:
214
+
215
+ if self.proxies and "wss" in self.proxies:
216
+ logger.info(f"Using proxy for websocket connection: {self.proxies['wss']}")
217
+ proxy = Proxy.from_url(self.proxies["wss"])
218
+ connect = proxy_connect(ws_url, ssl=ssl_context, proxy=proxy)
219
+ elif self.proxies and "https" in self.proxies:
220
+ logger.info(f"Using proxy for websocket connection: {self.proxies['https']}")
221
+ proxy = Proxy.from_url(self.proxies["https"])
222
+ connect = proxy_connect(ws_url, ssl=ssl_context, proxy=proxy)
223
+ else:
224
+ logger.debug(f"Not using proxy for websocket connection.")
225
+ connect = websockets.connect(ws_url, ssl=ssl_context)
226
+
227
+ async with connect as _websocket:
201
228
  self.websocket = _websocket
202
229
  logger.info("WebSocket Opened.")
203
230
  msg = {'id': str(uuid.uuid4()),
@@ -216,4 +243,4 @@ class WebexWebsocketClient(object):
216
243
  logger.error('could not create device info')
217
244
  raise Exception("No WDM device info")
218
245
  # trigger re-connect
219
- asyncio.get_event_loop().run_until_complete(_connect_and_listen())
246
+ asyncio.get_event_loop().run_until_complete(_connect_and_listen())
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: webex-bot
3
- Version: 0.5.0
3
+ Version: 0.5.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
@@ -16,6 +16,7 @@ Classifier: Programming Language :: Python :: 3.8
16
16
  Classifier: Programming Language :: Python :: 3.9
17
17
  Requires-Python: >=3.8
18
18
  Description-Content-Type: text/markdown
19
+ Provides-Extra: proxy
19
20
  License-File: LICENSE
20
21
 
21
22
  # Introduction
@@ -53,6 +54,10 @@ You can find a sample project, using OpenAI/ChatGPT with this library here: http
53
54
 
54
55
  `pip install webex_bot`
55
56
 
57
+ If you need optional proxy support, use this command instead:
58
+
59
+ `pip install webex_bot[proxy]`
60
+
56
61
  2. On the Webex Developer portal, create a new [bot token][3] and expose it as an environment variable.
57
62
 
58
63
  ```sh
@@ -71,11 +76,19 @@ import os
71
76
  from webex_bot.commands.echo import EchoCommand
72
77
  from webex_bot.webex_bot import WebexBot
73
78
 
79
+ # (Optional) Proxy configuration
80
+ # Supports https or wss proxy, wss prioritized.
81
+ proxies = {
82
+ 'https': 'http://proxy.esl.example.com:80',
83
+ 'wss': 'socks5://proxy.esl.example.com:1080'
84
+ }
85
+
74
86
  # Create a Bot Object
75
87
  bot = WebexBot(teams_bot_token=os.getenv("WEBEX_TEAMS_ACCESS_TOKEN"),
76
88
  approved_rooms=['06586d8d-6aad-4201-9a69-0bf9eeb5766e'],
77
89
  bot_name="My Teams Ops Bot",
78
- include_demo_commands=True)
90
+ include_demo_commands=True,
91
+ proxies=proxies)
79
92
 
80
93
  # Add new commands for the bot to listen out for.
81
94
  bot.add_command(EchoCommand())
@@ -353,13 +366,16 @@ and off you go!
353
366
 
354
367
  ### 0.5.0 (2024-Apr-25)
355
368
 
356
- * Add max backoff time (#55)
357
- * Attached files. Help, threading and log level overrides. (#54)
358
- * add stop() call to gracefully exit the bot (#42)
359
- * feat(20231212): add help image size parameter (#46)
360
- * update websockets to 11.0.3 (#43)
369
+ * Add max backoff time ([#55][pr55])
370
+ * Attached files. Help, threading and log level overrides. ([#54][pr54])
371
+ * add stop() call to gracefully exit the bot ([#42][pr42])
372
+ * feat(20231212): add help image size parameter ([#46][pr46])
373
+ * update websockets to 11.0.3 ([#43][pr43])
361
374
  * Fix for help_command syntax issue
362
375
 
376
+ ### 0.5.1 (2024-Apr-25)
377
+
378
+ * Add Proxy Support. ([#56][pr56])
363
379
 
364
380
  [1]: https://github.com/aaugustin/websockets
365
381
 
@@ -375,6 +391,18 @@ and off you go!
375
391
 
376
392
  [7]: https://eurl.io/#TeBLqZjLs
377
393
 
394
+ [pr43]: https://github.com/fbradyirl/webex_bot/pull/43
395
+
396
+ [pr46]: https://github.com/fbradyirl/webex_bot/pull/46
397
+
398
+ [pr42]: https://github.com/fbradyirl/webex_bot/pull/42
399
+
400
+ [pr54]: https://github.com/fbradyirl/webex_bot/pull/54
401
+
402
+ [pr55]: https://github.com/fbradyirl/webex_bot/pull/55
403
+
404
+ [pr56]: https://github.com/fbradyirl/webex_bot/pull/56
405
+
378
406
  [i1]: https://github.com/fbradyirl/webex_bot/issues/1
379
407
 
380
408
  [i2]: https://github.com/fbradyirl/webex_bot/issues/2
@@ -2,3 +2,6 @@ webexteamssdk==1.6.1
2
2
  coloredlogs
3
3
  websockets==11.0.3
4
4
  backoff
5
+
6
+ [proxy]
7
+ websockets_proxy>=0.1.1
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