warp-beacon 2.3.25__py3-none-any.whl → 2.3.27__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/telegram/bot.py +16 -10
- warp_beacon/telegram/caption_shortener.py +1 -1
- warp_beacon/telegram/handlers.py +4 -0
- {warp_beacon-2.3.25.dist-info → warp_beacon-2.3.27.dist-info}/METADATA +1 -1
- {warp_beacon-2.3.25.dist-info → warp_beacon-2.3.27.dist-info}/RECORD +10 -10
- {warp_beacon-2.3.25.dist-info → warp_beacon-2.3.27.dist-info}/LICENSE +0 -0
- {warp_beacon-2.3.25.dist-info → warp_beacon-2.3.27.dist-info}/WHEEL +0 -0
- {warp_beacon-2.3.25.dist-info → warp_beacon-2.3.27.dist-info}/entry_points.txt +0 -0
- {warp_beacon-2.3.25.dist-info → warp_beacon-2.3.27.dist-info}/top_level.txt +0 -0
warp_beacon/__version__.py
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
__version__ = "2.3.
|
1
|
+
__version__ = "2.3.27"
|
2
2
|
|
warp_beacon/telegram/bot.py
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
import os
|
2
2
|
import signal
|
3
3
|
|
4
|
+
import logging
|
5
|
+
|
4
6
|
import html
|
5
7
|
|
6
8
|
import uvloop
|
@@ -20,12 +22,11 @@ from warp_beacon.storage import Storage
|
|
20
22
|
from warp_beacon.uploader import AsyncUploader
|
21
23
|
from warp_beacon.jobs.upload_job import UploadJob
|
22
24
|
from warp_beacon.jobs.types import JobType
|
25
|
+
from warp_beacon.jobs import Origin
|
23
26
|
from warp_beacon.telegram.utils import Utils
|
24
27
|
from warp_beacon.telegram.caption_shortener import CaptionShortner
|
25
28
|
from warp_beacon.scheduler.scheduler import IGScheduler
|
26
29
|
|
27
|
-
import logging
|
28
|
-
|
29
30
|
class Bot(object):
|
30
31
|
storage = None
|
31
32
|
uploader = None
|
@@ -42,6 +43,8 @@ class Bot(object):
|
|
42
43
|
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", level=logging.INFO
|
43
44
|
)
|
44
45
|
|
46
|
+
logging.getLogger("pyrogram").setLevel(logging.ERROR)
|
47
|
+
|
45
48
|
db_connect = DBClient()
|
46
49
|
self.storage = Storage(db_connect)
|
47
50
|
|
@@ -107,7 +110,7 @@ class Bot(object):
|
|
107
110
|
self.client.run()
|
108
111
|
|
109
112
|
def stop(self) -> None:
|
110
|
-
logging.info("Warp Beacon terminating. This may take a while ...")
|
113
|
+
logging.info("Warp Beacon is terminating. This may take a while ...")
|
111
114
|
self.scheduler.stop()
|
112
115
|
self.downloader.stop_all()
|
113
116
|
self.uploader.stop_all()
|
@@ -162,12 +165,15 @@ class Bot(object):
|
|
162
165
|
def build_signature_caption(self, job: UploadJob) -> str:
|
163
166
|
caption = ""
|
164
167
|
is_group = job.chat_type in (ChatType.GROUP, ChatType.SUPERGROUP)
|
168
|
+
is_youtube = job.job_origin is Origin.YOUTUBE
|
165
169
|
if job.canonical_name:
|
166
|
-
if is_group and CaptionShortner.need_short(job.canonical_name):
|
170
|
+
if is_group and not is_youtube and CaptionShortner.need_short(job.canonical_name):
|
167
171
|
caption = f"{html.escape(CaptionShortner.smart_truncate_html(job.canonical_name))} ..."
|
168
172
|
job.short_text = True
|
169
|
-
|
170
|
-
|
173
|
+
# Captions only for YouTube in groups; empty otherwise.
|
174
|
+
# Might be too long for Telegram, so we skip them.
|
175
|
+
if is_youtube and is_group:
|
176
|
+
caption = f"<b>{caption}</b>"
|
171
177
|
if is_group:
|
172
178
|
if job.canonical_name:
|
173
179
|
caption += "\n—\n"
|
@@ -347,6 +353,7 @@ class Bot(object):
|
|
347
353
|
if job.media_type is not JobType.COLLECTION:
|
348
354
|
render_donates = os.environ.get("ENABLE_DONATES", None) == "true"
|
349
355
|
keyboard_buttons = [[]]
|
356
|
+
# short_text is True only for groups
|
350
357
|
if job.short_text:
|
351
358
|
keyboard_buttons[0].append(InlineKeyboardButton("📖 Read more", callback_data=f"read_more:{job.job_origin.value}:{job.uniq_id}"))
|
352
359
|
if render_donates:
|
@@ -417,10 +424,9 @@ class Bot(object):
|
|
417
424
|
elif msg.photo:
|
418
425
|
tg_file_ids.append(msg.photo.file_id + ':image')
|
419
426
|
logging.info("Uploaded to Telegram")
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
# self.client.send_message()
|
427
|
+
if job.chat_type not in (ChatType.GROUP, ChatType.SUPERGROUP):
|
428
|
+
if job.canonical_name:
|
429
|
+
await self.send_text(chat_id=job.user_id, text=job.canonical_name)
|
424
430
|
break
|
425
431
|
except MultiMediaTooLong as e:
|
426
432
|
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,
|
@@ -4,7 +4,7 @@ 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=HscoHU4qFcWrkOvyuw52PtDdKw2LAfH6ZQTQowjSIRg,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
|
@@ -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=
|
40
|
-
warp_beacon/telegram/caption_shortener.py,sha256=
|
41
|
-
warp_beacon/telegram/handlers.py,sha256=
|
39
|
+
warp_beacon/telegram/bot.py,sha256=yaibrtwslZnxCHocDvuf0CrExwAw6lWgaX7ts9yz87E,16996
|
40
|
+
warp_beacon/telegram/caption_shortener.py,sha256=EnguNCF52ne7y4P-iJAbI6K3sqoJqJbND_dX5Fhwkv0,1549
|
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.27.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
46
|
+
warp_beacon-2.3.27.dist-info/METADATA,sha256=579ruuxb3n9RUt4JTKN-7YSOpBRh2m_GTVmzmm5WjwQ,21723
|
47
|
+
warp_beacon-2.3.27.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
|
48
|
+
warp_beacon-2.3.27.dist-info/entry_points.txt,sha256=eSB61Rb89d56WY0O-vEIQwkn18J-4CMrJcLA_R_8h3g,119
|
49
|
+
warp_beacon-2.3.27.dist-info/top_level.txt,sha256=2iKFlYwJ-meO9sCX4OGEP1hhQN17t2KFksQ5dXMhXUA,1103
|
50
|
+
warp_beacon-2.3.27.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|