From 45eec691d18b59d91a21426084fc55520a511d96 Mon Sep 17 00:00:00 2001 From: Hafitz Setya Date: Mon, 19 Jul 2021 04:10:48 +0700 Subject: [PATCH] Add Timezon config Signed-off-by: breakdowns --- README.md | 3 ++- app.json | 5 +++++ bot/__init__.py | 7 +++++++ bot/__main__.py | 5 ++--- bot/modules/config.py | 2 +- config_sample.env | 1 + requirements.txt | 2 +- 7 files changed, 19 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 353112f..f270412 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ tgx, yts, eztv, torlock, rarbg letsupload.io, hxfile.co, anonfiles.com, bayfiles.com, antfiles, fembed.com, fembed.net, femax20.com, layarkacaxxi.icu, fcdn.stream, sbplay.org, naniplay.com, naniplay.nanime.in, naniplay.nanime.biz, sbembed.com, -streamtape.com, streamsb.net, feurl.com, pixeldrain.com, +streamtape.com, streamsb.net, feurl.com, pixeldrain.com, racaty.net, 1drv.ms (Only works for file not folder or business account), uptobox.com (Uptobox account must be premium) ``` @@ -167,6 +167,7 @@ Fill up rest of the fields. Meaning of each fields are discussed below: - **MEGA_LIMIT**: To limit downloading Mega (leave space between number and unit, Available units is (gb or GB, tb or TB), Examples: ```100 gb, 100 GB, 10 tb, 10 TB``` - **TORRENT_DIRECT_LIMIT**: To limit the Torrent/Direct mirror size, Leave space between number and unit. Available units is (gb or GB, tb or TB), Examples: ```100 gb, 100 GB, 10 tb, 10 TB``` - **TAR_UNZIP_LIMIT**: To limit mirroring as Tar or unzipmirror. Available units is (gb or GB, tb or TB), Examples: ```100 gb, 100 GB, 10 tb, 10 TB``` +- **TIMEZONE**: To change time zone in ```/stats``` command (**NOTE**: Default time zone using ```Asia/Jakarta```) - **IMAGE_URL**: Show Image/Logo in /start message. Fill value of image your link image, use telegra.ph or any direct link image. - **VIEW_LINK**: View Link button to open file Index Link in browser instead of direct download link, you can figure out if it's compatible with your Index code or not, open any video from you Index and check if the END of link from browser link bar is `?a=view`, if yes make it `True` it will work (Compatible with [Bhadoo Index](https://gitlab.com/ParveenBhadooOfficial/Google-Drive-Index) Code) - **UPTOBOX_TOKEN**: Uptobox token to mirror uptobox links. Get it from [Uptobox Premium Account](https://uptobox.com/my_account). diff --git a/app.json b/app.json index 02791c6..30a6916 100644 --- a/app.json +++ b/app.json @@ -152,6 +152,11 @@ "description": "Fill your shortener api key if you are using shortener.", "required": false }, + "TIMEZONE": { + "description": "To change time zone in /stats command.", + "value": "Asia/Jakarta", + "required": false + }, "IMAGE_URL": { "description": "Show Image/Logo in /start message, Use telegra.ph or any direct link image.", "value": "https://telegra.ph/file/db03910496f06094f1f7a.jpg", diff --git a/bot/__init__.py b/bot/__init__.py index caab34f..f219413 100644 --- a/bot/__init__.py +++ b/bot/__init__.py @@ -348,6 +348,13 @@ try: UNFINISHED_PROGRESS_STR = '○' except KeyError: UNFINISHED_PROGRESS_STR = '○' +try: + TIMEZONE = getConfig('TIMEZONE') + if len(TIMEZONE) == 0: + TIMEZONE = 'Asia/Jakarta' +except KeyError: + TIMEZONE = 'Asia/Jakarta' + updater = tg.Updater(token=BOT_TOKEN) bot = updater.bot dispatcher = updater.dispatcher diff --git a/bot/__main__.py b/bot/__main__.py index faa051f..bfe0fa7 100644 --- a/bot/__main__.py +++ b/bot/__main__.py @@ -11,7 +11,7 @@ import time from telegram import ParseMode from telegram.ext import CommandHandler -from bot import bot, dispatcher, updater, botStartTime, IMAGE_URL, IGNORE_PENDING_REQUESTS +from bot import bot, dispatcher, updater, botStartTime, IMAGE_URL, IGNORE_PENDING_REQUESTS, TIMEZONE from bot.helper.ext_utils import fs_utils from bot.helper.telegram_helper.bot_commands import BotCommands from bot.helper.telegram_helper.message_utils import * @@ -19,8 +19,7 @@ from .helper.ext_utils.bot_utils import get_readable_file_size, get_readable_tim from .helper.telegram_helper.filters import CustomFilters from bot.helper.telegram_helper import button_build from .modules import authorize, list, cancel_mirror, mirror_status, mirror, clone, watch, shell, eval, torrent_search, delete, speedtest, usage, mediainfo, count, config, updates - -now=datetime.now(pytz.timezone('Asia/Jakarta')) +now=datetime.now(pytz.timezone(f'{TIMEZONE}')) def stats(update, context): diff --git a/bot/modules/config.py b/bot/modules/config.py index cd303ab..c6fbaeb 100644 --- a/bot/modules/config.py +++ b/bot/modules/config.py @@ -192,7 +192,7 @@ async def config_button(_, query): elif data == '9': return await query.message.edit( __header__.format(data) - + f"**[ Others Config ]**\n\n**VIEW_LINK:** `{VIEW_LINK}`\n\n**STATUS_LIMIT:** `{STATUS_LIMIT}`\n\n**DOWNLOAD_STATUS_UPDATE_INTERVAL:** `{DOWNLOAD_STATUS_UPDATE_INTERVAL}`\n\n**IGNORE_PENDING_REQUESTS:** `{IGNORE_PENDING_REQUESTS}`\n\n**AUTO_DELETE_MESSAGE_DURATION:** `{AUTO_DELETE_MESSAGE_DURATION}`\n\n**DOWNLOAD_DIR:** `{DOWNLOAD_DIR}`\n\n**IMAGE_URL:** `{IMAGE_URL}`\n\n**DATABASE_URL:** `{DB_URI}`", + + f"**[ Others Config ]**\n\n**VIEW_LINK:** `{VIEW_LINK}`\n\n**STATUS_LIMIT:** `{STATUS_LIMIT}`\n\n**TIMEZONE:** `{TIMEZONE}`\n\n**DOWNLOAD_STATUS_UPDATE_INTERVAL:** `{DOWNLOAD_STATUS_UPDATE_INTERVAL}`\n\n**IGNORE_PENDING_REQUESTS:** `{IGNORE_PENDING_REQUESTS}`\n\n**AUTO_DELETE_MESSAGE_DURATION:** `{AUTO_DELETE_MESSAGE_DURATION}`\n\n**DOWNLOAD_DIR:** `{DOWNLOAD_DIR}`\n\n**IMAGE_URL:** `{IMAGE_URL}`\n\n**DATABASE_URL:** `{DB_URI}`", reply_markup=types.InlineKeyboardMarkup( [ [ diff --git a/config_sample.env b/config_sample.env index 843d081..35d9b5d 100644 --- a/config_sample.env +++ b/config_sample.env @@ -32,6 +32,7 @@ STOP_DUPLICATE_CLONE = "" STOP_DUPLICATE_MEGA = "" SHORTENER = "" SHORTENER_API = "" +TIMEZONE = "Asia/Jakarta" IMAGE_URL = "https://telegra.ph/file/db03910496f06094f1f7a.jpg" # If you want to use Credentials externally from Index Links, fill these vars with the direct links # These are optional, if you don't know, simply leave them, don't fill anything in them. diff --git a/requirements.txt b/requirements.txt index d491a11..016006b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ aiohttp aria2p appdirs beautifulsoup4 -cloudscrape==0.4.2 +cloudscrape feedparser gitpython google-api-python-client