python-trueconf-bot 1.2.0b2__py3-none-any.whl → 1.2.0b3__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.2.0b2
3
+ Version: 1.2.0b3
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
@@ -32,7 +32,8 @@ Requires-Dist: aiohttp
32
32
  Requires-Dist: async-property
33
33
  Requires-Dist: typing_extensions>=4.15.0
34
34
  Requires-Dist: python-magic>=0.4.27; sys_platform != "win32"
35
- Requires-Dist: python-magic-bin>=0.4.27; sys_platform == "win32"
35
+ Requires-Dist: python-magic-bin==0.4.14; sys_platform == "win32"
36
+ Requires-Dist: filetype
36
37
  Dynamic: license-file
37
38
 
38
39
  <p align="center">
@@ -1,6 +1,6 @@
1
- python_trueconf_bot-1.2.0b2.dist-info/licenses/LICENSE,sha256=ftDuEzhr-yY_dsfpEQ2SKAP_dEAO-iPt96MBZq_K48o,1684
1
+ python_trueconf_bot-1.2.0b3.dist-info/licenses/LICENSE,sha256=ftDuEzhr-yY_dsfpEQ2SKAP_dEAO-iPt96MBZq_K48o,1684
2
2
  trueconf/__init__.py,sha256=JRFC0ca_JhwlDuzcnZ1r9bflnAmQyMYhJr_hBRYcdpw,394
3
- trueconf/_version.py,sha256=ZjrumRj9rT0zIxBYOWkwYCDiswIhQcklxX-StaUjgb0,528
3
+ trueconf/_version.py,sha256=7H8SA-1_9DEkIbOfO6crcWVsMc0zLorp-x-w34yA3HQ,528
4
4
  trueconf/exceptions.py,sha256=dtY54xAdatBxmQlUy3moGpeMVz2NOKHIKPIOrX7MyHQ,500
5
5
  trueconf/loggers.py,sha256=dOAwgGLPcrmD6aZI5jA3J9eMunbbOAvPRguk6zWMcNo,125
6
6
  trueconf/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -62,7 +62,7 @@ trueconf/methods/upload_file.py,sha256=6xMB3ulv5vYuRoc2Ykbc84xZ3Mpbwk27RbFk4IfX-
62
62
  trueconf/types/__init__.py,sha256=UBMPMau1Q2X1LcLQEPdfck0g7BEqTzYZXyHjDSlKta8,1353
63
63
  trueconf/types/author_box.py,sha256=G_9AxpBGIbZyWEHCfKg_DkEbte9f9FWt-JQ05gro3bU,356
64
64
  trueconf/types/chat_participant.py,sha256=08sxIkiLK0IFZdHF_yApWHroNZTd-9tj9dVBOvZcI1E,328
65
- trueconf/types/input_file.py,sha256=h1G90oLw3Pw3AQd0WPHN3doay8OlD12PKKCkIzSIMWw,16353
65
+ trueconf/types/input_file.py,sha256=6e8rh0dQqJirv5xIk5LcButio-OVI0FpH0BGP_v1HBU,16745
66
66
  trueconf/types/last_message.py,sha256=kIuQ1C6Pn_K5Q3JMEdnHfG09Bc-tWk_lmhnjPkWF6Cs,1314
67
67
  trueconf/types/message.py,sha256=B3YlwT35J31CMeiaXueVkRz5HruBoDNKNoN7tgB2UUQ,23127
68
68
  trueconf/types/parser.py,sha256=ZUTgAX4-nDrBPn7kwiEDKoO9QGLU8hITMO2Gr_X_Gr0,4462
@@ -128,7 +128,7 @@ trueconf/types/responses/upload_file_response.py,sha256=CmhLmby4MVny8KmfQ1aHW6UD
128
128
  trueconf/utils/__init__.py,sha256=6CrEznKfUTDKL0IH-CNJJOOW-Vx22aokR7tmHORyUUU,135
129
129
  trueconf/utils/generate_secret_for_survey.py,sha256=_rJttL9lsY3zeVxAzV5iSnHLRFslIBvYzj_qn03xMh8,241
130
130
  trueconf/utils/token.py,sha256=WZWiYH3mQsltPoKgF9szVb1R-rxPZYqs3-GPS1WXb0Q,2305
131
- python_trueconf_bot-1.2.0b2.dist-info/METADATA,sha256=I7si5S2Jqumkhr1LGlvC1ychLv0aKZoXCZbj0omTlSY,5688
132
- python_trueconf_bot-1.2.0b2.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
133
- python_trueconf_bot-1.2.0b2.dist-info/top_level.txt,sha256=GjgYdn_osTUuU-H8f59VhIS7MY44xLV7-D7veywJaeY,9
134
- python_trueconf_bot-1.2.0b2.dist-info/RECORD,,
131
+ python_trueconf_bot-1.2.0b3.dist-info/METADATA,sha256=gndRUZFc99GlENQxGbpTsuGjKAGb5gtEjq-XvrulRFg,5712
132
+ python_trueconf_bot-1.2.0b3.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
133
+ python_trueconf_bot-1.2.0b3.dist-info/top_level.txt,sha256=GjgYdn_osTUuU-H8f59VhIS7MY44xLV7-D7veywJaeY,9
134
+ python_trueconf_bot-1.2.0b3.dist-info/RECORD,,
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.2.0b2'
22
- __version_tuple__ = version_tuple = (1, 2, 0, 'b2')
21
+ __version__ = version = '1.2.0b3'
22
+ __version_tuple__ = version_tuple = (1, 2, 0, 'b3')
23
23
 
24
24
  __commit_id__ = commit_id = None
@@ -4,12 +4,13 @@ import io
4
4
  import re
5
5
  import os
6
6
  import aiofiles
7
+ import filetype
7
8
  from urllib.parse import urlparse, unquote
8
9
  from abc import ABC, abstractmethod
9
10
  from pathlib import Path
10
11
  from typing import Any, Dict, Optional
11
12
  from typing_extensions import Self
12
- from mimetypes import guess_type
13
+ from mimetypes import guess_type, guess_extension
13
14
  from trueconf import loggers
14
15
  from httpx import AsyncClient
15
16
  import warnings
@@ -32,8 +33,14 @@ except ImportError as e:
32
33
  ) from e
33
34
 
34
35
  def detect_mime_type(data: bytes, file_name: str = "") -> str:
35
- mime_type = guess_type(file_name or "")[0]
36
- if not mime_type and magic:
36
+ mime_type, _ = guess_type(file_name) if file_name else (None, None)
37
+
38
+ if not mime_type or mime_type == "application/octet-stream":
39
+ kind = filetype.guess(data)
40
+ if kind:
41
+ mime_type = kind.mime
42
+
43
+ if (not mime_type or mime_type == "application/octet-stream") and magic:
37
44
  try:
38
45
  mime_type = magic.from_buffer(data, mime=True)
39
46
  except Exception as error:
@@ -90,6 +97,11 @@ class InputFile(ABC):
90
97
  file_size: int | None = None,
91
98
  mime_type: str | None = None,
92
99
  ):
100
+
101
+ if not guess_type(file_name)[0]:
102
+ if ext := guess_extension(mime_type):
103
+ file_name = file_name+ext
104
+
93
105
  self.file_name = file_name
94
106
  self.file_size = file_size
95
107
  self.mime_type = mime_type