warp-beacon 2.6.0__py3-none-any.whl → 2.6.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.
- warp_beacon/__version__.py +1 -1
- warp_beacon/telegram/bot.py +27 -17
- {warp_beacon-2.6.0.dist-info → warp_beacon-2.6.2.dist-info}/METADATA +1 -1
- {warp_beacon-2.6.0.dist-info → warp_beacon-2.6.2.dist-info}/RECORD +8 -8
- {warp_beacon-2.6.0.dist-info → warp_beacon-2.6.2.dist-info}/WHEEL +0 -0
- {warp_beacon-2.6.0.dist-info → warp_beacon-2.6.2.dist-info}/entry_points.txt +0 -0
- {warp_beacon-2.6.0.dist-info → warp_beacon-2.6.2.dist-info}/licenses/LICENSE +0 -0
- {warp_beacon-2.6.0.dist-info → warp_beacon-2.6.2.dist-info}/top_level.txt +0 -0
warp_beacon/__version__.py
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
__version__ = "2.6.
|
1
|
+
__version__ = "2.6.2"
|
2
2
|
|
warp_beacon/telegram/bot.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import os
|
2
2
|
import signal
|
3
|
+
import asyncio
|
3
4
|
from typing import Optional, Union
|
4
5
|
|
5
6
|
import logging
|
@@ -29,6 +30,7 @@ from warp_beacon.telegram.caption_shortener import CaptionShortner
|
|
29
30
|
from warp_beacon.scheduler.scheduler import IGScheduler
|
30
31
|
|
31
32
|
class Bot(object):
|
33
|
+
should_exit = None
|
32
34
|
storage = None
|
33
35
|
uploader = None
|
34
36
|
downloader = None
|
@@ -37,6 +39,7 @@ class Bot(object):
|
|
37
39
|
handlers = None
|
38
40
|
placeholder = None
|
39
41
|
scheduler = None
|
42
|
+
me = None
|
40
43
|
|
41
44
|
def __init__(self, tg_bot_name: str, tg_token: str, tg_api_id: str, tg_api_hash: str) -> None:
|
42
45
|
# Enable logging
|
@@ -46,10 +49,12 @@ class Bot(object):
|
|
46
49
|
|
47
50
|
logging.getLogger("pyrogram").setLevel(logging.ERROR)
|
48
51
|
|
52
|
+
logging.info("Starting Warp Beacon version '%s' ...", __version__)
|
53
|
+
|
49
54
|
db_connect = DBClient()
|
50
55
|
self.storage = Storage(db_connect)
|
51
56
|
|
52
|
-
|
57
|
+
self.should_exit = asyncio.Event()
|
53
58
|
|
54
59
|
workers_amount = min(32, os.cpu_count() + 4)
|
55
60
|
|
@@ -64,14 +69,6 @@ class Bot(object):
|
|
64
69
|
workers=int(os.environ.get("TG_WORKERS_POOL_SIZE", default=workers_amount))
|
65
70
|
)
|
66
71
|
|
67
|
-
this = self
|
68
|
-
def __terminator() -> None:
|
69
|
-
this.stop()
|
70
|
-
|
71
|
-
stop_signals = (signal.SIGINT, signal.SIGTERM, signal.SIGABRT)
|
72
|
-
for sig in stop_signals:
|
73
|
-
self.client.loop.add_signal_handler(sig, __terminator)
|
74
|
-
|
75
72
|
self.uploader = AsyncUploader(
|
76
73
|
storage=self.storage,
|
77
74
|
admin_message_callback=self.send_text_to_admin,
|
@@ -86,10 +83,6 @@ class Bot(object):
|
|
86
83
|
|
87
84
|
self.scheduler = IGScheduler(self.downloader)
|
88
85
|
|
89
|
-
self.downloader.start()
|
90
|
-
self.uploader.start()
|
91
|
-
self.scheduler.start()
|
92
|
-
|
93
86
|
self.handlers = Handlers(self)
|
94
87
|
|
95
88
|
self.client.add_handler(MessageHandler(self.handlers.start, filters.command("start")))
|
@@ -102,20 +95,37 @@ class Bot(object):
|
|
102
95
|
|
103
96
|
self.placeholder = PlaceholderMessage(self)
|
104
97
|
|
105
|
-
self.client.run()
|
106
|
-
|
107
98
|
def __del__(self) -> None:
|
108
99
|
self.stop()
|
109
|
-
logging.info("Warp Beacon terminated.")
|
110
100
|
|
111
101
|
def start(self) -> None:
|
112
|
-
self.client.run()
|
102
|
+
self.client.run(self.run())
|
103
|
+
|
104
|
+
async def run(self) -> None:
|
105
|
+
loop = asyncio.get_running_loop()
|
106
|
+
for sig in (signal.SIGINT, signal.SIGTERM, signal.SIGABRT):
|
107
|
+
loop.add_signal_handler(sig, self.should_exit.set)
|
108
|
+
async with self.client:
|
109
|
+
self.me = await self.client.get_me()
|
110
|
+
self.client.me = self.me
|
111
|
+
if self.me.is_premium:
|
112
|
+
os.environ["TG_PREMIUM"] = "true"
|
113
|
+
self.downloader.start()
|
114
|
+
self.uploader.start()
|
115
|
+
self.scheduler.start()
|
116
|
+
logging.info("Warp Beacon version '%s' started", __version__)
|
117
|
+
await self.should_exit.wait()
|
118
|
+
|
119
|
+
self.stop()
|
120
|
+
logging.info("Warp Beacon version '%s' terminated.", __version__)
|
113
121
|
|
114
122
|
def stop(self) -> None:
|
115
123
|
logging.info("Warp Beacon is terminating. This may take a while ...")
|
116
124
|
self.scheduler.stop()
|
117
125
|
self.downloader.stop_all()
|
118
126
|
self.uploader.stop_all()
|
127
|
+
if self.client and self.client.is_initialized and self.client.is_connected:
|
128
|
+
asyncio.run_coroutine_threadsafe(self.client.stop(), self.client.loop)
|
119
129
|
|
120
130
|
async def send_text(self, chat_id: int, text: str, reply_id: int = None) -> int:
|
121
131
|
try:
|
@@ -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=OXunv8OkkN2NkzEL8Kuh2VDP7KhnkKZHA9K5JHIJsB8,23
|
8
8
|
warp_beacon/warp_beacon.py,sha256=7KEtZDj-pdhtl6m-zFLsSojs1ZR4o7L0xbqtdmYPvfE,342
|
9
9
|
warp_beacon/yt_auth.py,sha256=GUTKqYr_tzDC-07Lx_ahWXSag8EyLxXBUnQbDBIkEmk,6022
|
10
10
|
warp_beacon/compress/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -38,15 +38,15 @@ warp_beacon/scraper/youtube/youtube.py,sha256=ctHPmTfNO-5dcYeh1K4_PkB6MQRVgByr4E
|
|
38
38
|
warp_beacon/storage/__init__.py,sha256=0Vajd0oITKJfu2vmNx5uQSt3-L6vwIvUYWJo8HZCjco,3398
|
39
39
|
warp_beacon/storage/mongo.py,sha256=qC4ZiO8XXvPnP0rJwz4CJx42pqFsyAjCiW10W5QdT6E,527
|
40
40
|
warp_beacon/telegram/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
41
|
-
warp_beacon/telegram/bot.py,sha256=
|
41
|
+
warp_beacon/telegram/bot.py,sha256=e1NVqw997i_0XhJwcKtbSK4vdh96w7KFeJSgQzjmpMI,18718
|
42
42
|
warp_beacon/telegram/caption_shortener.py,sha256=EnguNCF52ne7y4P-iJAbI6K3sqoJqJbND_dX5Fhwkv0,1549
|
43
43
|
warp_beacon/telegram/handlers.py,sha256=uvR6TPHSqdSxigp3wR-ewiE6t3TvVcbVLVcYGwkgD2s,9559
|
44
44
|
warp_beacon/telegram/placeholder_message.py,sha256=wN9-BRiyrtHG-EvXtZkGJHt2CX71munQ57ITttjt0mw,6400
|
45
45
|
warp_beacon/telegram/utils.py,sha256=9uebX53G16mV7ER7WgfdWBLFHHw14S8HBt9URrIskg0,4440
|
46
46
|
warp_beacon/uploader/__init__.py,sha256=e75mOcC0vrUVjrTNMQzVUTgXGdGo4J6n8t5doOnYG5I,5616
|
47
|
-
warp_beacon-2.6.
|
48
|
-
warp_beacon-2.6.
|
49
|
-
warp_beacon-2.6.
|
50
|
-
warp_beacon-2.6.
|
51
|
-
warp_beacon-2.6.
|
52
|
-
warp_beacon-2.6.
|
47
|
+
warp_beacon-2.6.2.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
48
|
+
warp_beacon-2.6.2.dist-info/METADATA,sha256=Tgzx7p1ULX3Mg9VMIkkdsOLBi3NMLCXlP-dl30Rk4rI,22625
|
49
|
+
warp_beacon-2.6.2.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
|
50
|
+
warp_beacon-2.6.2.dist-info/entry_points.txt,sha256=eSB61Rb89d56WY0O-vEIQwkn18J-4CMrJcLA_R_8h3g,119
|
51
|
+
warp_beacon-2.6.2.dist-info/top_level.txt,sha256=4ML0-mXsezLtRXyxQUntL_ktc5HX9npTeQWzvV8kFvA,1161
|
52
|
+
warp_beacon-2.6.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|