telethon all the way
Browse files- App/Worker.py +4 -8
- App/__init__.py +4 -4
- requirements.txt +1 -0
App/Worker.py
CHANGED
@@ -12,7 +12,7 @@ celery = Celery()
|
|
12 |
celery.config_from_object(celery_config)
|
13 |
celery.conf.update(
|
14 |
# Other Celery configuration settings
|
15 |
-
|
16 |
)
|
17 |
|
18 |
|
@@ -70,13 +70,9 @@ def render_video(directory: str, output_directory: str):
|
|
70 |
def cleanup_temp_directory(
|
71 |
temp_dir: str, output_dir: str, chat_id: int = -1002069945904
|
72 |
):
|
73 |
-
async_to_sync(SendVideo)(temp_dir, output_dir, chat_id=-1002069945904)
|
74 |
-
|
75 |
-
|
76 |
-
async def SendVideo(temp_dir: str, output_dir: str, chat_id: int = -1002069945904):
|
77 |
try:
|
78 |
-
|
79 |
-
-1002069945904,
|
80 |
)
|
81 |
finally:
|
82 |
# Cleanup: Remove the temporary directory
|
@@ -97,7 +93,7 @@ def celery_task(video_task: EditorRequest):
|
|
97 |
render_video.si(temp_dir, output_dir),
|
98 |
cleanup_temp_directory.si(temp_dir, output_dir),
|
99 |
).apply_async(
|
100 |
-
link_error=handle_error
|
101 |
) # Link the tasks and handle errors
|
102 |
|
103 |
|
|
|
12 |
celery.config_from_object(celery_config)
|
13 |
celery.conf.update(
|
14 |
# Other Celery configuration settings
|
15 |
+
CELERYD_LOG_LEVEL="DEBUG", # Set log level to DEBUG for the worker
|
16 |
)
|
17 |
|
18 |
|
|
|
70 |
def cleanup_temp_directory(
|
71 |
temp_dir: str, output_dir: str, chat_id: int = -1002069945904
|
72 |
):
|
|
|
|
|
|
|
|
|
73 |
try:
|
74 |
+
bot.send_file(
|
75 |
+
chat_id - 1002069945904, file=output_dir, caption="Your video caption"
|
76 |
)
|
77 |
finally:
|
78 |
# Cleanup: Remove the temporary directory
|
|
|
93 |
render_video.si(temp_dir, output_dir),
|
94 |
cleanup_temp_directory.si(temp_dir, output_dir),
|
95 |
).apply_async(
|
96 |
+
# link_error=handle_error
|
97 |
) # Link the tasks and handle errors
|
98 |
|
99 |
|
App/__init__.py
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
-
from
|
|
|
2 |
import os
|
3 |
|
4 |
TELEGRAM_SESSION = os.environ.get("TELEGRAM_SESSION")
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
"Editor", session_string=TELEGRAM_SESSION, workdir="/srv", workers=9
|
9 |
)
|
|
|
1 |
+
from telethon.sync import TelegramClient
|
2 |
+
from telethon.sessions import StringSession
|
3 |
import os
|
4 |
|
5 |
TELEGRAM_SESSION = os.environ.get("TELEGRAM_SESSION")
|
6 |
|
7 |
+
bot: TelegramClient = TelegramClient(
|
8 |
+
StringSession(TELEGRAM_SESSION),
|
|
|
9 |
)
|
requirements.txt
CHANGED
@@ -19,6 +19,7 @@ requests
|
|
19 |
ujson
|
20 |
psutil
|
21 |
celery
|
|
|
22 |
python-multipart
|
23 |
git+https://github.com/redis/redis-py.git
|
24 |
TgCrypto
|
|
|
19 |
ujson
|
20 |
psutil
|
21 |
celery
|
22 |
+
telethon
|
23 |
python-multipart
|
24 |
git+https://github.com/redis/redis-py.git
|
25 |
TgCrypto
|