warp-beacon 2.3.24__py3-none-any.whl → 2.3.26__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.
- warp_beacon/__version__.py +1 -1
- warp_beacon/jobs/abstract.py +2 -0
- warp_beacon/telegram/bot.py +7 -1
- warp_beacon/telegram/handlers.py +26 -18
- {warp_beacon-2.3.24.dist-info → warp_beacon-2.3.26.dist-info}/METADATA +1 -1
- {warp_beacon-2.3.24.dist-info → warp_beacon-2.3.26.dist-info}/RECORD +10 -10
- {warp_beacon-2.3.24.dist-info → warp_beacon-2.3.26.dist-info}/LICENSE +0 -0
- {warp_beacon-2.3.24.dist-info → warp_beacon-2.3.26.dist-info}/WHEEL +0 -0
- {warp_beacon-2.3.24.dist-info → warp_beacon-2.3.26.dist-info}/entry_points.txt +0 -0
- {warp_beacon-2.3.24.dist-info → warp_beacon-2.3.26.dist-info}/top_level.txt +0 -0
warp_beacon/__version__.py
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
__version__ = "2.3.
|
1
|
+
__version__ = "2.3.26"
|
2
2
|
|
warp_beacon/jobs/abstract.py
CHANGED
@@ -13,6 +13,7 @@ class JobSettings(TypedDict):
|
|
13
13
|
job_id: uuid.UUID
|
14
14
|
message_id: int
|
15
15
|
chat_id: int
|
16
|
+
user_id: int
|
16
17
|
placeholder_message_id: int
|
17
18
|
local_media_path: str
|
18
19
|
local_compressed_media_path: str
|
@@ -49,6 +50,7 @@ class JobSettings(TypedDict):
|
|
49
50
|
class AbstractJob(ABC):
|
50
51
|
job_id: uuid.UUID = None
|
51
52
|
message_id: int = 0
|
53
|
+
user_id: int = 0
|
52
54
|
chat_id: int = 0
|
53
55
|
placeholder_message_id: int = 0
|
54
56
|
local_media_path: str = ""
|
warp_beacon/telegram/bot.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import os
|
2
2
|
import signal
|
3
|
+
from typing import Optional
|
3
4
|
|
4
5
|
import html
|
5
6
|
|
@@ -167,7 +168,8 @@ class Bot(object):
|
|
167
168
|
caption = f"{html.escape(CaptionShortner.smart_truncate_html(job.canonical_name))} ..."
|
168
169
|
job.short_text = True
|
169
170
|
else:
|
170
|
-
caption = f"<b>{html.escape(job.canonical_name)}</b>"
|
171
|
+
#caption = f"<b>{html.escape(job.canonical_name)}</b>"
|
172
|
+
return "" # may be too long so empty, no needed
|
171
173
|
if is_group:
|
172
174
|
if job.canonical_name:
|
173
175
|
caption += "\n—\n"
|
@@ -347,6 +349,7 @@ class Bot(object):
|
|
347
349
|
if job.media_type is not JobType.COLLECTION:
|
348
350
|
render_donates = os.environ.get("ENABLE_DONATES", None) == "true"
|
349
351
|
keyboard_buttons = [[]]
|
352
|
+
# short_text is True only for groups
|
350
353
|
if job.short_text:
|
351
354
|
keyboard_buttons[0].append(InlineKeyboardButton("📖 Read more", callback_data=f"read_more:{job.job_origin.value}:{job.uniq_id}"))
|
352
355
|
if render_donates:
|
@@ -417,6 +420,9 @@ class Bot(object):
|
|
417
420
|
elif msg.photo:
|
418
421
|
tg_file_ids.append(msg.photo.file_id + ':image')
|
419
422
|
logging.info("Uploaded to Telegram")
|
423
|
+
if job.chat_type not in (ChatType.GROUP, ChatType.SUPERGROUP):
|
424
|
+
if job.canonical_name:
|
425
|
+
await self.send_text(chat_id=job.user_id, text=job.canonical_name)
|
420
426
|
break
|
421
427
|
except MultiMediaTooLong as e:
|
422
428
|
logging.error("Failed to upload due telegram limitations :(")
|
warp_beacon/telegram/handlers.py
CHANGED
@@ -38,6 +38,7 @@ class Handlers(object):
|
|
38
38
|
UploadJob(
|
39
39
|
tg_file_id=d["tg_file_id"],
|
40
40
|
chat_id=message.chat.id,
|
41
|
+
user_id=message.from_user.id,
|
41
42
|
media_type=JobType[d["media_type"].upper()],
|
42
43
|
message_id=message.id,
|
43
44
|
chat_type=message.chat.type,
|
@@ -179,6 +180,7 @@ class Handlers(object):
|
|
179
180
|
message_id=effective_message_id,
|
180
181
|
media_type=JobType.COLLECTION,
|
181
182
|
chat_id=chat.id,
|
183
|
+
user_id=message.from_user.id,
|
182
184
|
chat_type=message.chat.type,
|
183
185
|
source_username=Utils.extract_message_author(message),
|
184
186
|
message_leftover=msg_leftover
|
@@ -196,6 +198,7 @@ class Handlers(object):
|
|
196
198
|
message_id=effective_message_id,
|
197
199
|
media_type=media_type,
|
198
200
|
chat_id=chat.id,
|
201
|
+
user_id=message.from_user.id,
|
199
202
|
chat_type=message.chat.type,
|
200
203
|
source_username=Utils.extract_message_author(message),
|
201
204
|
canonical_name=canonical_name,
|
@@ -207,6 +210,7 @@ class Handlers(object):
|
|
207
210
|
url=url,
|
208
211
|
message_id=effective_message_id,
|
209
212
|
chat_id=chat.id,
|
213
|
+
user_id=message.from_user.id,
|
210
214
|
in_process=self.bot.uploader.is_inprocess(uniq_id),
|
211
215
|
uniq_id=uniq_id,
|
212
216
|
job_origin=origin,
|
@@ -243,29 +247,33 @@ class Handlers(object):
|
|
243
247
|
first_entity = {}
|
244
248
|
if db_results:
|
245
249
|
first_entity = db_results[0]
|
250
|
+
|
251
|
+
text = first_entity.get("canonical_name", "Failed to fetch data.")
|
246
252
|
|
247
253
|
try:
|
248
|
-
|
249
|
-
|
250
|
-
text
|
251
|
-
|
252
|
-
callback_query_id=query.id,
|
253
|
-
show_alert=True,
|
254
|
-
text=text
|
254
|
+
await client.send_message(
|
255
|
+
query.from_user.id,
|
256
|
+
text,
|
257
|
+
parse_mode=ParseMode.HTML
|
255
258
|
)
|
256
|
-
except Exception as
|
257
|
-
logging.warning("read_more_handler: Failed for uniq_id='%s', origin='%s'", uniq_id, origin)
|
258
|
-
logging.exception(e)
|
259
|
-
|
259
|
+
except Exception as _:
|
260
260
|
try:
|
261
|
-
error_text = str(e)
|
262
|
-
if len(error_text) > 200:
|
263
|
-
error_text = error_text[:197] + "..."
|
264
|
-
|
265
261
|
await client.answer_callback_query(
|
266
262
|
callback_query_id=query.id,
|
267
263
|
show_alert=True,
|
268
|
-
text=
|
264
|
+
text="You haven’t messaged the bot yet. Please start the chat using the /start bot command."
|
269
265
|
)
|
270
|
-
except Exception as
|
271
|
-
|
266
|
+
except Exception as e:
|
267
|
+
logging.warning("Failed to return error to user about TG restrictions!")
|
268
|
+
logging.exception(e)
|
269
|
+
return
|
270
|
+
|
271
|
+
try:
|
272
|
+
await client.answer_callback_query(
|
273
|
+
callback_query_id=query.id,
|
274
|
+
show_alert=True,
|
275
|
+
text="Check your private chat — I've sent you the message!"
|
276
|
+
)
|
277
|
+
except Exception as e:
|
278
|
+
logging.error("Failed to report sent message status!")
|
279
|
+
logging.exception(e)
|
@@ -4,12 +4,12 @@ var/warp_beacon/accounts.json,sha256=OsXdncs6h88xrF_AP6_WDCK1waGBn9SR-uYdIeK37GM
|
|
4
4
|
var/warp_beacon/placeholder.gif,sha256=cE5CGJVaop4Sx21zx6j4AyoHU0ncmvQuS2o6hJfEH88,6064
|
5
5
|
var/warp_beacon/proxies.json,sha256=VnjlQDXumOEq72ZFjbh6IqHS1TEHqn8HPYAZqWCeSIA,95
|
6
6
|
warp_beacon/__init__.py,sha256=_rThNODmz0nDp_n4mWo_HKaNFE5jk1_7cRhHyYaencI,163
|
7
|
-
warp_beacon/__version__.py,sha256=
|
7
|
+
warp_beacon/__version__.py,sha256=wev-73bni4Bt8uUVCdcTf6qvQHVHQ7M8RdnMsVpXnB0,24
|
8
8
|
warp_beacon/warp_beacon.py,sha256=7KEtZDj-pdhtl6m-zFLsSojs1ZR4o7L0xbqtdmYPvfE,342
|
9
9
|
warp_beacon/compress/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
10
10
|
warp_beacon/compress/video.py,sha256=_PDMVYCyzLYxHv1uZmmzGcG_8rjaZr7BTXsXTTy_oS4,2846
|
11
11
|
warp_beacon/jobs/__init__.py,sha256=ED8_tPle4iL4kqNW0apAVkgNQtRRTnYfAJwBjO1g0JY,180
|
12
|
-
warp_beacon/jobs/abstract.py,sha256=
|
12
|
+
warp_beacon/jobs/abstract.py,sha256=7DZWGI2KfBmAF9qwftmVBrOa2Szd0vrlp24aQKl95ho,3119
|
13
13
|
warp_beacon/jobs/download_job.py,sha256=5HiPcnJppFMhO14___3eSkoMygM3y-vhpGkMAuNhK7s,854
|
14
14
|
warp_beacon/jobs/types.py,sha256=Ae8zINgbs7cOcYkYoOCOACA7duyhnIGMQAJ_SJB1QRQ,176
|
15
15
|
warp_beacon/jobs/upload_job.py,sha256=_ul4psPej1jLEs-BMcMR80GbXDSmm38jE9yoZtecclY,741
|
@@ -36,15 +36,15 @@ warp_beacon/scraper/youtube/youtube.py,sha256=fGrbjBngvvNdpzhb1yZVedNW0_tCrLc31V
|
|
36
36
|
warp_beacon/storage/__init__.py,sha256=0Vajd0oITKJfu2vmNx5uQSt3-L6vwIvUYWJo8HZCjco,3398
|
37
37
|
warp_beacon/storage/mongo.py,sha256=qC4ZiO8XXvPnP0rJwz4CJx42pqFsyAjCiW10W5QdT6E,527
|
38
38
|
warp_beacon/telegram/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
39
|
-
warp_beacon/telegram/bot.py,sha256=
|
39
|
+
warp_beacon/telegram/bot.py,sha256=8CiZPWCW7d7MrF51_AU-xv9HN9Rc56ElpEA8qxHRIKo,16803
|
40
40
|
warp_beacon/telegram/caption_shortener.py,sha256=6J4Dp35mOmJEyctiuN8WXM39bkQ13m78HoghsYX3fbU,1548
|
41
|
-
warp_beacon/telegram/handlers.py,sha256=
|
41
|
+
warp_beacon/telegram/handlers.py,sha256=XXIfdV_RCj7tyZMPXchuKmGoDdweOaR08ADDaBPWo_U,9426
|
42
42
|
warp_beacon/telegram/placeholder_message.py,sha256=wN9-BRiyrtHG-EvXtZkGJHt2CX71munQ57ITttjt0mw,6400
|
43
43
|
warp_beacon/telegram/utils.py,sha256=9uebX53G16mV7ER7WgfdWBLFHHw14S8HBt9URrIskg0,4440
|
44
44
|
warp_beacon/uploader/__init__.py,sha256=5KRWsxPRGuQ56YhCEnJsXnb-yQp8dpvWEsPDf0dD-fw,4964
|
45
|
-
warp_beacon-2.3.
|
46
|
-
warp_beacon-2.3.
|
47
|
-
warp_beacon-2.3.
|
48
|
-
warp_beacon-2.3.
|
49
|
-
warp_beacon-2.3.
|
50
|
-
warp_beacon-2.3.
|
45
|
+
warp_beacon-2.3.26.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
46
|
+
warp_beacon-2.3.26.dist-info/METADATA,sha256=5RJrfPr8VU7WTEX_8oS2l0wDS_chvS4su8JcqWQktqs,21723
|
47
|
+
warp_beacon-2.3.26.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
|
48
|
+
warp_beacon-2.3.26.dist-info/entry_points.txt,sha256=eSB61Rb89d56WY0O-vEIQwkn18J-4CMrJcLA_R_8h3g,119
|
49
|
+
warp_beacon-2.3.26.dist-info/top_level.txt,sha256=2iKFlYwJ-meO9sCX4OGEP1hhQN17t2KFksQ5dXMhXUA,1103
|
50
|
+
warp_beacon-2.3.26.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|