python-trueconf-bot 1.4.1__py3-none-any.whl → 1.4.2__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-trueconf-bot
3
- Version: 1.4.1
3
+ Version: 1.4.2
4
4
  Summary: Lightweight and powerful framework for the TrueConf Server Chatbot API
5
5
  Author-email: TrueConf LLC <info@trueconf.com>, Anton Baadzhi <baadzhianton@gmail.com>
6
6
  License-Expression: BSD-3-Clause-Clear
@@ -1,12 +1,12 @@
1
- python_trueconf_bot-1.4.1.dist-info/licenses/LICENSE,sha256=ftDuEzhr-yY_dsfpEQ2SKAP_dEAO-iPt96MBZq_K48o,1684
1
+ python_trueconf_bot-1.4.2.dist-info/licenses/LICENSE,sha256=ftDuEzhr-yY_dsfpEQ2SKAP_dEAO-iPt96MBZq_K48o,1684
2
2
  trueconf/__init__.py,sha256=Ka9VLhsdu-jZPndOQI1QpUXWldpu8xTC2BfgW51Px5U,481
3
- trueconf/_version.py,sha256=R2qm3sd7mdm0pKpioGIIqoJSfPQ63QQwTYQPVKW0mt8,520
3
+ trueconf/_version.py,sha256=M92Udlou7mMHSdniRD3tru4stsJfoWt74G8vTdtA1kI,528
4
4
  trueconf/exceptions.py,sha256=JlnOybf6XBVKGYPPN3STlruupdfQXrLdeZ_FbtUuMIs,7653
5
5
  trueconf/loggers.py,sha256=4dnq14qFo6fJ8SKZJCRZd0iJDYRqmcuX-ccv5FezxlQ,594
6
6
  trueconf/middleware.py,sha256=7yaS4UjZSrPb-lv5STmX8qGg1OamYbO5Nd5-IjPtbU4,2281
7
7
  trueconf/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
8
  trueconf/client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- trueconf/client/bot.py,sha256=SfiNqCOr6_py2paBTqlnWYVRNZQYnVwLWLCbjgw_nMM,79151
9
+ trueconf/client/bot.py,sha256=hbb9glTZB6dn591PuY3tKUD_y7xsiY13ToXVtvOZDMA,79769
10
10
  trueconf/client/context_controller.py,sha256=_aItNHblyFbEqRsnbOM3ESgPqg2Pkji7xidTx0gb6zk,660
11
11
  trueconf/client/session.py,sha256=CvHjxQXbkUyyS1r7YCFVL8al37zOYtnhw5ACNLJJDOc,1751
12
12
  trueconf/dispatcher/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -149,13 +149,13 @@ trueconf/types/responses/upload_file_response.py,sha256=CmhLmby4MVny8KmfQ1aHW6UD
149
149
  trueconf/utils/__init__.py,sha256=O1ZS6uwnlZpSH19FEodZQ2fOLyua0SJYsIgEO70UIRg,39
150
150
  trueconf/utils/_generate_secret_for_survey.py,sha256=QclUSR_T2PU2mkUSCI3LG72HMTBTHAHaYFCm8gkevwI,242
151
151
  trueconf/utils/_ssl.py,sha256=pMEGtCQtnaeo5zD9cS15Sry2hBnUkDx8I0BVov9PV1c,1419
152
- trueconf/utils/_token.py,sha256=vbZp8hwHu59DzqMpE0MqeQ7EM55txLkKNDFV031Up6Q,2336
152
+ trueconf/utils/_token.py,sha256=JltP8nFJaiSeM8BAIAdG664br3I3r2LW3pQRWIexOdo,2504
153
153
  trueconf/utils/_version_checker.py,sha256=U1AB0KgASTCuI68r7SiLGnWeeSy3T1yFqLNg8h3fjM0,2029
154
154
  trueconf/utils/split_text.py,sha256=0HTVv63kLo2gx1r-ImM47ejTR4X_uDkNr5QMxvWdTBo,18807
155
155
  trueconf/utils/formatting/__init__.py,sha256=Ii9rEamQdy8R0pVbmDf3xbdB4TtmgYyu2-RWRTCXukw,261
156
156
  trueconf/utils/formatting/decorations.py,sha256=iQzCdFBELn16llCgTTPk43K5-BzY6BGPc1M3V2Q0tPQ,2175
157
157
  trueconf/utils/formatting/text.py,sha256=pOW07TIV5vfvtWmGa2i2l_Q0UjFM6QMuowmsAjE9nyo,6867
158
- python_trueconf_bot-1.4.1.dist-info/METADATA,sha256=eo80EIOml1BZEu0Vva-jTvt8wRZ75lfVlewjoGAilM8,5700
159
- python_trueconf_bot-1.4.1.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
160
- python_trueconf_bot-1.4.1.dist-info/top_level.txt,sha256=GjgYdn_osTUuU-H8f59VhIS7MY44xLV7-D7veywJaeY,9
161
- python_trueconf_bot-1.4.1.dist-info/RECORD,,
158
+ python_trueconf_bot-1.4.2.dist-info/METADATA,sha256=HYWuDK5ieWsw2uN7P9cHyV6ArUv1azJUCJyhk4mP7GE,5700
159
+ python_trueconf_bot-1.4.2.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
160
+ python_trueconf_bot-1.4.2.dist-info/top_level.txt,sha256=GjgYdn_osTUuU-H8f59VhIS7MY44xLV7-D7veywJaeY,9
161
+ python_trueconf_bot-1.4.2.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (82.0.1)
2
+ Generator: setuptools (83.0.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
trueconf/_version.py CHANGED
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
18
18
  commit_id: str | None
19
19
  __commit_id__: str | None
20
20
 
21
- __version__ = version = '1.4.1'
22
- __version_tuple__ = version_tuple = (1, 4, 1)
21
+ __version__ = version = '1.4.2'
22
+ __version_tuple__ = version_tuple = (1, 4, 2)
23
23
 
24
- __commit_id__ = commit_id = None
24
+ __commit_id__ = commit_id = 'g0603f16c3'
trueconf/client/bot.py CHANGED
@@ -7,6 +7,7 @@ import signal
7
7
  import websockets
8
8
  import warnings
9
9
  import random
10
+ from re import search
10
11
  from pathlib import Path
11
12
  from aiohttp import ClientSession, ClientTimeout, TCPConnector, FormData
12
13
  from async_property import async_cached_property
@@ -244,15 +245,30 @@ class Bot:
244
245
  return None
245
246
 
246
247
  async def __get_server_version(self):
248
+ port = "4307"
249
+ async with httpx.AsyncClient(verify=self.ssl_context, timeout=self.timeout) as client:
247
250
  try:
248
- async with httpx.AsyncClient(verify=self.ssl_context, timeout=self.timeout) as client:
249
- response = await client.get(f"{self._protocol}://{self.server}:{self.port}/api/v4/server")
250
- version = response.json().get("product").get("version")
251
- loggers.chatbot.info(f"📦 Server version resolved: {version}")
251
+ response = await client.get(
252
+ f"{self._protocol}://{self.server}:{self.port}/api/v4/endpoints/connects"
253
+ )
254
+ port = response.json()["connects"][0].split(":")[-1]
255
+ except (httpx.RequestError, KeyError, IndexError) as e:
256
+ loggers.chatbot.debug(f"Failed to get endpoints/connects: {e}")
257
+
258
+ try:
259
+ resp = await client.get(
260
+ f"http://{self.server}:{port}/vsstatus",
261
+ timeout=self.timeout,
262
+ )
263
+ m = search(r"TrueConf Server \b(\d{1,2}\.\d{1,2}\.\d{1,2}\.\d{1,5})\b", resp.text)
264
+ if m:
265
+ version = m.group(1)
266
+ loggers.chatbot.info(f"📦 Server engine version resolved: {version}")
252
267
  return version
253
- except Exception as e:
254
- loggers.chatbot.error(f"Failed to get server version: {e}")
255
- return None
268
+ except httpx.RequestError as e:
269
+ loggers.chatbot.debug(f"Failed to get server engine version: {e}")
270
+
271
+ return None
256
272
 
257
273
  @property
258
274
  def token(self) -> str:
@@ -277,12 +293,12 @@ class Bot:
277
293
  return await self.__get_domain_name()
278
294
 
279
295
  @async_cached_property
280
- async def server_version(self) -> str:
296
+ async def server_version(self) -> str | None:
281
297
  """
282
- Returns the domain name of the TrueConf server.
298
+ Returns the server version of the TrueConf server.
283
299
 
284
300
  Returns:
285
- str: Domain name of the connected server.
301
+ str | None: Version of the connected server, or None if unavailable.
286
302
  """
287
303
 
288
304
  return await self.__get_server_version()
trueconf/utils/_token.py CHANGED
@@ -4,7 +4,7 @@ from datetime import datetime
4
4
  from functools import lru_cache
5
5
  from typing import Optional
6
6
 
7
- from httpx import Client, HTTPStatusError
7
+ from httpx import Client, HTTPStatusError, ConnectTimeout
8
8
  from ._ssl import SSLVerify
9
9
  from ..exceptions import TokenValidationError, InvalidGrantError
10
10
 
@@ -27,10 +27,11 @@ def _get_auth_token(
27
27
  "password": str(password)
28
28
  }
29
29
  with Client(timeout=timeout, verify=ssl_context) as client:
30
- r = client.post(url, json=params)
31
-
32
30
  try:
31
+ r = client.post(url, json=params)
33
32
  r.raise_for_status()
33
+ except ConnectTimeout:
34
+ raise ConnectionError(f"Cannot connect to {server}:{port}. Server may be down or unreachable.") from None
34
35
  except HTTPStatusError as e:
35
36
  if e.response.status_code == 401:
36
37
  if r.json().get("error_description", False):