From 30195dba3f0e5ed57f93f309a999194ccd86d6e5 Mon Sep 17 00:00:00 2001 From: BennyThink Date: Sun, 27 Feb 2022 10:47:54 +0800 Subject: [PATCH] add custom text --- ytdlbot/constant.py | 2 ++ ytdlbot/tasks.py | 2 +- ytdlbot/ytdl_bot.py | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ytdlbot/constant.py b/ytdlbot/constant.py index 1cff7e7..bc8ceec 100644 --- a/ytdlbot/constant.py +++ b/ytdlbot/constant.py @@ -7,6 +7,7 @@ __author__ = "Benny " +import os import time from config import (AFD_LINK, COFFEE_LINK, ENABLE_CELERY, ENABLE_VIP, EX, @@ -91,6 +92,7 @@ Your current settings: Video quality: **{0}** Sending format: **{1}** """ + custom_text = os.getenv("CUSTOM_TEXT", "") def remaining_quota_caption(self, chat_id): if not ENABLE_VIP: diff --git a/ytdlbot/tasks.py b/ytdlbot/tasks.py index 813f91e..9075f8b 100644 --- a/ytdlbot/tasks.py +++ b/ytdlbot/tasks.py @@ -341,7 +341,7 @@ def gen_cap(chat_id, url, video_path): remain = bot_text.remaining_quota_caption(chat_id) worker = get_dl_source() cap = f"`{file_name}`\n\n{url}\n\nInfo: {meta['width']}x{meta['height']} {file_size}\t" \ - f"{meta['duration']}s\n{remain}\n{worker}" + f"{meta['duration']}s\n{remain}\n{worker}\n{bot_text.custom_text}" return cap, meta diff --git a/ytdlbot/ytdl_bot.py b/ytdlbot/ytdl_bot.py index 1a34f21..ca93b3a 100644 --- a/ytdlbot/ytdl_bot.py +++ b/ytdlbot/ytdl_bot.py @@ -85,7 +85,8 @@ def start_handler(client: "Client", message: "types.Message"): client.send_chat_action(from_id, "typing") greeting = bot_text.get_vip_greeting(from_id) quota = bot_text.remaining_quota_caption(from_id) - text = f"{greeting}{bot_text.start}\n\n{quota}" + custom_text = bot_text.custom_text + text = f"{greeting}{bot_text.start}\n\n{quota}\n{custom_text}" client.send_message(message.chat.id, text)