warp-beacon 2.2.45__py3-none-any.whl → 2.2.47__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,2 +1,2 @@
1
- __version__ = "2.2.45"
1
+ __version__ = "2.2.47"
2
2
 
@@ -153,7 +153,7 @@ class Bot(object):
153
153
  def build_signature_caption(self, job: UploadJob) -> str:
154
154
  caption = ""
155
155
  if job.canonical_name:
156
- caption = f"**{job.canonical_name}**"
156
+ caption = f"**{Utils.escape_markdown(job.canonical_name)}**"
157
157
  if job.chat_type in (ChatType.GROUP, ChatType.SUPERGROUP):
158
158
  if job.canonical_name:
159
159
  caption += "\n—\n"
@@ -95,3 +95,30 @@ class Utils(object):
95
95
  return message.sender_chat.title
96
96
  return ''
97
97
 
98
+ @staticmethod
99
+ def escape_markdown(text: str, version: int = 1, entity_type: str = None) -> str:
100
+ """
101
+ Helper function to escape telegram markup symbols.
102
+
103
+ Args:
104
+ text (:obj:`str`): The text.
105
+ version (:obj:`int` | :obj:`str`): Use to specify the version of telegrams Markdown.
106
+ Either ``1`` or ``2``. Defaults to ``1``.
107
+ entity_type (:obj:`str`, optional): For the entity types ``PRE``, ``CODE`` and the link
108
+ part of ``TEXT_LINKS``, only certain characters need to be escaped in ``MarkdownV2``.
109
+ See the official API documentation for details. Only valid in combination with
110
+ ``version=2``, will be ignored else.
111
+ """
112
+ if int(version) == 1:
113
+ escape_chars = r'_*`['
114
+ elif int(version) == 2:
115
+ if entity_type in ['pre', 'code']:
116
+ escape_chars = r'\`'
117
+ elif entity_type == 'text_link':
118
+ escape_chars = r'\)'
119
+ else:
120
+ escape_chars = r'_*[]()~`>#+-=|{}.!'
121
+ else:
122
+ raise ValueError('Markdown version must be either 1 or 2!')
123
+
124
+ return re.sub(f'([{re.escape(escape_chars)}])', r'\\\\\1', text)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: warp_beacon
3
- Version: 2.2.45
3
+ Version: 2.2.47
4
4
  Summary: Telegram bot for expanding external media links
5
5
  Home-page: https://github.com/sb0y/warp_beacon
6
6
  Author: Andrey Bagrintsev
@@ -3,7 +3,7 @@ lib/systemd/system/warp_beacon.service,sha256=lPmHqLqcI2eIV7nwHS0qcALQrznixqJuww
3
3
  var/warp_beacon/accounts.json,sha256=2QQMS9N_Z-TnfZq4U1vSUe4IKyZGmTFdgo8BoF4hQ7E,1710
4
4
  var/warp_beacon/placeholder.gif,sha256=cE5CGJVaop4Sx21zx6j4AyoHU0ncmvQuS2o6hJfEH88,6064
5
5
  warp_beacon/__init__.py,sha256=_rThNODmz0nDp_n4mWo_HKaNFE5jk1_7cRhHyYaencI,163
6
- warp_beacon/__version__.py,sha256=DxEBXV6-ZGc5Kxeu5OzEgsZe_Db7Q5vicwkF0hYJ9q8,24
6
+ warp_beacon/__version__.py,sha256=SWPlqKCukT_MyWGDqNRNEulaDsmsTYjOUf8rE9rxTtg,24
7
7
  warp_beacon/warp_beacon.py,sha256=7KEtZDj-pdhtl6m-zFLsSojs1ZR4o7L0xbqtdmYPvfE,342
8
8
  warp_beacon/compress/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
9
  warp_beacon/compress/video.py,sha256=_PDMVYCyzLYxHv1uZmmzGcG_8rjaZr7BTXsXTTy_oS4,2846
@@ -32,14 +32,14 @@ warp_beacon/scraper/youtube/shorts.py,sha256=RqMYDq4XHChtp-LdlxXyHej4h3NI3Qi9T8U
32
32
  warp_beacon/scraper/youtube/youtube.py,sha256=JvN5pVz0jtxCY9FGMl1dIg5Ccr2Kulaoxtym0Vb1QwQ,2224
33
33
  warp_beacon/storage/__init__.py,sha256=m86MDXBMtZZsTPLI2cD-pM5Xkh2g2NYVvp_dtW8eH0Q,3548
34
34
  warp_beacon/telegram/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
35
- warp_beacon/telegram/bot.py,sha256=yqqA9UFOnSA0XwgbIVnPyIPhGU8o0l-Gs3Dsx_agOFY,15383
35
+ warp_beacon/telegram/bot.py,sha256=1s7-tqhjy0bYvBpSuBSdPXKS9hEHDCwxkiq3_nXJKKQ,15406
36
36
  warp_beacon/telegram/handlers.py,sha256=xSNG_v4D4FaA5q1_5wXvJkjcDUhy5GaQnfpijJZpnPk,7039
37
37
  warp_beacon/telegram/placeholder_message.py,sha256=32U-R_IMPRJd-S5UwlpemLkArJOxCmO7whcynduSbMA,6418
38
- warp_beacon/telegram/utils.py,sha256=CeWXMwyzv2l4Af6I-wW2ySU490c-5k82sBhkjabv0n4,2452
38
+ warp_beacon/telegram/utils.py,sha256=K3SVcFZDGj1blfipl3eisnPaWOlxQkhqXQ10YF4BLNU,3483
39
39
  warp_beacon/uploader/__init__.py,sha256=rbfsm_eYcfsBRkiaG0glVgBNtQCEe7cVQTWEIAHz5aw,4763
40
- warp_beacon-2.2.45.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
41
- warp_beacon-2.2.45.dist-info/METADATA,sha256=b6S-qgTis7wV2ln0I52GwL4dv_jh6f4WyN2z7_89bUU,21251
42
- warp_beacon-2.2.45.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
43
- warp_beacon-2.2.45.dist-info/entry_points.txt,sha256=eSB61Rb89d56WY0O-vEIQwkn18J-4CMrJcLA_R_8h3g,119
44
- warp_beacon-2.2.45.dist-info/top_level.txt,sha256=ALb_Ft_eG-OY4_m0TWUifNUOZsrx483L-zw7G7vqXoc,971
45
- warp_beacon-2.2.45.dist-info/RECORD,,
40
+ warp_beacon-2.2.47.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
41
+ warp_beacon-2.2.47.dist-info/METADATA,sha256=NFXrRX6WAJEqFNhm6F-aToFlFeWf_QZsMB9fico5_Ps,21251
42
+ warp_beacon-2.2.47.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
43
+ warp_beacon-2.2.47.dist-info/entry_points.txt,sha256=eSB61Rb89d56WY0O-vEIQwkn18J-4CMrJcLA_R_8h3g,119
44
+ warp_beacon-2.2.47.dist-info/top_level.txt,sha256=ALb_Ft_eG-OY4_m0TWUifNUOZsrx483L-zw7G7vqXoc,971
45
+ warp_beacon-2.2.47.dist-info/RECORD,,