Join stop duplicate vars and minor changes
Signed-off-by: anas <e.anastayyar@gmail.com>
This commit is contained in:
parent
61c7c4d5cf
commit
aed6f58346
10
app.json
10
app.json
|
|
@ -128,18 +128,10 @@
|
||||||
"description": "To limit downloading Mega (leave space between number and unit, Available units is (gb or GB, tb or TB).",
|
"description": "To limit downloading Mega (leave space between number and unit, Available units is (gb or GB, tb or TB).",
|
||||||
"required": false
|
"required": false
|
||||||
},
|
},
|
||||||
"STOP_DUPLICATE_MIRROR": {
|
"STOP_DUPLICATE": {
|
||||||
"description": "If this field is set to True, bot will check file in Drive, if it is present in Drive, downloading will be stopped.",
|
"description": "If this field is set to True, bot will check file in Drive, if it is present in Drive, downloading will be stopped.",
|
||||||
"required": false
|
"required": false
|
||||||
},
|
},
|
||||||
"STOP_DUPLICATE_MEGA": {
|
|
||||||
"description": "If this field is set to True, bot will check file in Drive, if it is present in Drive, downloading Mega will be stopped.",
|
|
||||||
"required": false
|
|
||||||
},
|
|
||||||
"STOP_DUPLICATE_CLONE": {
|
|
||||||
"description": "If this field is set to True, bot will check file in Drive, if it is present in Drive, cloning will be stopped.",
|
|
||||||
"required": false
|
|
||||||
},
|
|
||||||
"IGNORE_PENDING_REQUESTS": {
|
"IGNORE_PENDING_REQUESTS": {
|
||||||
"description": "If you want the bot to ignore pending requests after it restarts, set this to True.",
|
"description": "If you want the bot to ignore pending requests after it restarts, set this to True.",
|
||||||
"required": false
|
"required": false
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,6 @@ if os.path.exists('sudo_users.txt'):
|
||||||
with open('sudo_users.txt', 'r+') as f:
|
with open('sudo_users.txt', 'r+') as f:
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
for line in lines:
|
for line in lines:
|
||||||
AUTHORIZED_CHATS.add(int(line.split()[0]))
|
|
||||||
SUDO_USERS.add(int(line.split()[0]))
|
SUDO_USERS.add(int(line.split()[0]))
|
||||||
try:
|
try:
|
||||||
achats = getConfig('AUTHORIZED_CHATS')
|
achats = getConfig('AUTHORIZED_CHATS')
|
||||||
|
|
@ -102,7 +101,6 @@ try:
|
||||||
schats = getConfig('SUDO_USERS')
|
schats = getConfig('SUDO_USERS')
|
||||||
schats = schats.split(" ")
|
schats = schats.split(" ")
|
||||||
for chats in schats:
|
for chats in schats:
|
||||||
AUTHORIZED_CHATS.add(int(chats))
|
|
||||||
SUDO_USERS.add(int(chats))
|
SUDO_USERS.add(int(chats))
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
@ -252,21 +250,13 @@ except KeyError:
|
||||||
BUTTON_SIX_NAME = None
|
BUTTON_SIX_NAME = None
|
||||||
BUTTON_SIX_URL = None
|
BUTTON_SIX_URL = None
|
||||||
try:
|
try:
|
||||||
STOP_DUPLICATE_MIRROR = getConfig('STOP_DUPLICATE_MIRROR')
|
STOP_DUPLICATE = getConfig('STOP_DUPLICATE')
|
||||||
if STOP_DUPLICATE_MIRROR.lower() == 'true':
|
if STOP_DUPLICATE.lower() == 'true':
|
||||||
STOP_DUPLICATE_MIRROR = True
|
STOP_DUPLICATE = True
|
||||||
else:
|
else:
|
||||||
STOP_DUPLICATE_MIRROR = False
|
STOP_DUPLICATE = False
|
||||||
except KeyError:
|
except KeyError:
|
||||||
STOP_DUPLICATE_MIRROR = False
|
STOP_DUPLICATE = False
|
||||||
try:
|
|
||||||
STOP_DUPLICATE_MEGA = getConfig('STOP_DUPLICATE_MEGA')
|
|
||||||
if STOP_DUPLICATE_MEGA.lower() == 'true':
|
|
||||||
STOP_DUPLICATE_MEGA = True
|
|
||||||
else:
|
|
||||||
STOP_DUPLICATE_MEGA = False
|
|
||||||
except KeyError:
|
|
||||||
STOP_DUPLICATE_MEGA = False
|
|
||||||
try:
|
try:
|
||||||
VIEW_LINK = getConfig('VIEW_LINK')
|
VIEW_LINK = getConfig('VIEW_LINK')
|
||||||
if VIEW_LINK.lower() == 'true':
|
if VIEW_LINK.lower() == 'true':
|
||||||
|
|
@ -275,14 +265,6 @@ try:
|
||||||
VIEW_LINK = False
|
VIEW_LINK = False
|
||||||
except KeyError:
|
except KeyError:
|
||||||
VIEW_LINK = False
|
VIEW_LINK = False
|
||||||
try:
|
|
||||||
STOP_DUPLICATE_CLONE = getConfig('STOP_DUPLICATE_CLONE')
|
|
||||||
if STOP_DUPLICATE_CLONE.lower() == 'true':
|
|
||||||
STOP_DUPLICATE_CLONE = True
|
|
||||||
else:
|
|
||||||
STOP_DUPLICATE_CLONE = False
|
|
||||||
except KeyError:
|
|
||||||
STOP_DUPLICATE_CLONE = False
|
|
||||||
try:
|
try:
|
||||||
IS_TEAM_DRIVE = getConfig('IS_TEAM_DRIVE')
|
IS_TEAM_DRIVE = getConfig('IS_TEAM_DRIVE')
|
||||||
if IS_TEAM_DRIVE.lower() == 'true':
|
if IS_TEAM_DRIVE.lower() == 'true':
|
||||||
|
|
|
||||||
|
|
@ -40,8 +40,6 @@ class DbManger:
|
||||||
self.conn.commit()
|
self.conn.commit()
|
||||||
self.disconnect()
|
self.disconnect()
|
||||||
AUTHORIZED_CHATS.remove(chat_id)
|
AUTHORIZED_CHATS.remove(chat_id)
|
||||||
if chat_id in SUDO_USERS:
|
|
||||||
SUDO_USERS.remove(chat_id)
|
|
||||||
return 'Unauthorized successfully'
|
return 'Unauthorized successfully'
|
||||||
|
|
||||||
def db_addsudo(self,chat_id: int):
|
def db_addsudo(self,chat_id: int):
|
||||||
|
|
@ -61,7 +59,6 @@ class DbManger:
|
||||||
self.cur.execute(sql)
|
self.cur.execute(sql)
|
||||||
self.conn.commit()
|
self.conn.commit()
|
||||||
self.disconnect()
|
self.disconnect()
|
||||||
AUTHORIZED_CHATS.add(chat_id)
|
|
||||||
SUDO_USERS.add(chat_id)
|
SUDO_USERS.add(chat_id)
|
||||||
return 'Successfully Authorized and promoted as Sudo'
|
return 'Successfully Authorized and promoted as Sudo'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
from bot import aria2, download_dict_lock, STOP_DUPLICATE_MIRROR, TORRENT_DIRECT_LIMIT, TAR_UNZIP_LIMIT
|
from bot import aria2, download_dict_lock, STOP_DUPLICATE, TORRENT_DIRECT_LIMIT, TAR_UNZIP_LIMIT
|
||||||
from bot.helper.mirror_utils.upload_utils.gdriveTools import GoogleDriveHelper
|
from bot.helper.mirror_utils.upload_utils.gdriveTools import GoogleDriveHelper
|
||||||
from bot.helper.ext_utils.bot_utils import *
|
from bot.helper.ext_utils.bot_utils import *
|
||||||
from .download_helper import DownloadHelper
|
from .download_helper import DownloadHelper
|
||||||
|
|
@ -16,11 +16,11 @@ class AriaDownloadHelper(DownloadHelper):
|
||||||
|
|
||||||
@new_thread
|
@new_thread
|
||||||
def __onDownloadStarted(self, api, gid):
|
def __onDownloadStarted(self, api, gid):
|
||||||
if STOP_DUPLICATE_MIRROR or TORRENT_DIRECT_LIMIT is not None or TAR_UNZIP_LIMIT is not None:
|
if STOP_DUPLICATE or TORRENT_DIRECT_LIMIT is not None or TAR_UNZIP_LIMIT is not None:
|
||||||
sleep(1)
|
sleep(1)
|
||||||
dl = getDownloadByGid(gid)
|
dl = getDownloadByGid(gid)
|
||||||
download = aria2.get_download(gid)
|
download = aria2.get_download(gid)
|
||||||
if STOP_DUPLICATE_MIRROR:
|
if STOP_DUPLICATE:
|
||||||
LOGGER.info(f"Checking File/Folder if already in Drive...")
|
LOGGER.info(f"Checking File/Folder if already in Drive...")
|
||||||
sleep(1)
|
sleep(1)
|
||||||
sname = aria2.get_download(gid).name
|
sname = aria2.get_download(gid).name
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import os
|
||||||
from bot.helper.ext_utils.bot_utils import new_thread, get_mega_link_type, get_readable_file_size
|
from bot.helper.ext_utils.bot_utils import new_thread, get_mega_link_type, get_readable_file_size
|
||||||
from bot.helper.mirror_utils.status_utils.mega_download_status import MegaDownloadStatus
|
from bot.helper.mirror_utils.status_utils.mega_download_status import MegaDownloadStatus
|
||||||
from bot.helper.mirror_utils.upload_utils.gdriveTools import GoogleDriveHelper
|
from bot.helper.mirror_utils.upload_utils.gdriveTools import GoogleDriveHelper
|
||||||
from bot import MEGA_LIMIT, STOP_DUPLICATE_MEGA, TAR_UNZIP_LIMIT
|
from bot import MEGA_LIMIT, STOP_DUPLICATE, TAR_UNZIP_LIMIT
|
||||||
import random
|
import random
|
||||||
import string
|
import string
|
||||||
|
|
||||||
|
|
@ -164,7 +164,7 @@ class MegaDownloadHelper:
|
||||||
node = folder_api.authorizeNode(mega_listener.node)
|
node = folder_api.authorizeNode(mega_listener.node)
|
||||||
if mega_listener.error is not None:
|
if mega_listener.error is not None:
|
||||||
return listener.onDownloadError(str(mega_listener.error))
|
return listener.onDownloadError(str(mega_listener.error))
|
||||||
if STOP_DUPLICATE_MEGA:
|
if STOP_DUPLICATE:
|
||||||
LOGGER.info(f'Checking File/Folder if already in Drive')
|
LOGGER.info(f'Checking File/Folder if already in Drive')
|
||||||
mname = node.getName()
|
mname = node.getName()
|
||||||
if listener.isTar:
|
if listener.isTar:
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import logging
|
import logging
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
from bot import LOGGER, download_dict, download_dict_lock, app, STOP_DUPLICATE_MIRROR
|
from bot import LOGGER, download_dict, download_dict_lock, app, STOP_DUPLICATE
|
||||||
from .download_helper import DownloadHelper
|
from .download_helper import DownloadHelper
|
||||||
from ..status_utils.telegram_download_status import TelegramDownloadStatus
|
from ..status_utils.telegram_download_status import TelegramDownloadStatus
|
||||||
from bot.helper.telegram_helper.message_utils import sendMarkup, sendStatusMessage
|
from bot.helper.telegram_helper.message_utils import sendMarkup, sendStatusMessage
|
||||||
|
|
@ -100,7 +100,7 @@ class TelegramDownloadHelper(DownloadHelper):
|
||||||
path = path + name
|
path = path + name
|
||||||
|
|
||||||
if download:
|
if download:
|
||||||
if STOP_DUPLICATE_MIRROR:
|
if STOP_DUPLICATE:
|
||||||
LOGGER.info(f"Checking File/Folder if already in Drive...")
|
LOGGER.info(f"Checking File/Folder if already in Drive...")
|
||||||
if self.__listener.isTar:
|
if self.__listener.isTar:
|
||||||
name = name + ".tar"
|
name = name + ".tar"
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ class CustomFilters:
|
||||||
class _AuthorizedUserFilter(MessageFilter):
|
class _AuthorizedUserFilter(MessageFilter):
|
||||||
def filter(self, message):
|
def filter(self, message):
|
||||||
id = message.from_user.id
|
id = message.from_user.id
|
||||||
return bool(id in AUTHORIZED_CHATS or id == OWNER_ID)
|
return bool(id in AUTHORIZED_CHATS or id in SUDO_USERS or id == OWNER_ID)
|
||||||
|
|
||||||
authorized_user = _AuthorizedUserFilter()
|
authorized_user = _AuthorizedUserFilter()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -112,9 +112,6 @@ def addSudo(update, context):
|
||||||
if DB_URI is not None:
|
if DB_URI is not None:
|
||||||
msg = DbManger().db_addsudo(user_id)
|
msg = DbManger().db_addsudo(user_id)
|
||||||
else:
|
else:
|
||||||
with open('authorized_chats.txt', 'a') as file:
|
|
||||||
file.write(f'{user_id}\n')
|
|
||||||
AUTHORIZED_CHATS.add(user_id)
|
|
||||||
with open('sudo_users.txt', 'a') as file:
|
with open('sudo_users.txt', 'a') as file:
|
||||||
file.write(f'{user_id}\n')
|
file.write(f'{user_id}\n')
|
||||||
SUDO_USERS.add(user_id)
|
SUDO_USERS.add(user_id)
|
||||||
|
|
@ -131,9 +128,6 @@ def addSudo(update, context):
|
||||||
if DB_URI is not None:
|
if DB_URI is not None:
|
||||||
msg = DbManger().db_addsudo(user_id)
|
msg = DbManger().db_addsudo(user_id)
|
||||||
else:
|
else:
|
||||||
with open('authorized_chats.txt', 'a') as file:
|
|
||||||
file.write(f'{user_id}\n')
|
|
||||||
AUTHORIZED_CHATS.add(user_id)
|
|
||||||
with open('sudo_users.txt', 'a') as file:
|
with open('sudo_users.txt', 'a') as file:
|
||||||
file.write(f'{user_id}\n')
|
file.write(f'{user_id}\n')
|
||||||
SUDO_USERS.add(user_id)
|
SUDO_USERS.add(user_id)
|
||||||
|
|
@ -154,7 +148,6 @@ def removeSudo(update, context):
|
||||||
if DB_URI is not None:
|
if DB_URI is not None:
|
||||||
msg = DbManger().db_rmsudo(user_id)
|
msg = DbManger().db_rmsudo(user_id)
|
||||||
else:
|
else:
|
||||||
AUTHORIZED_CHATS.remove(user_id)
|
|
||||||
SUDO_USERS.remove(user_id)
|
SUDO_USERS.remove(user_id)
|
||||||
msg = 'Demoted'
|
msg = 'Demoted'
|
||||||
else:
|
else:
|
||||||
|
|
@ -168,16 +161,11 @@ def removeSudo(update, context):
|
||||||
if DB_URI is not None:
|
if DB_URI is not None:
|
||||||
msg = DbManger().db_rmsudo(user_id)
|
msg = DbManger().db_rmsudo(user_id)
|
||||||
else:
|
else:
|
||||||
AUTHORIZED_CHATS.remove(user_id)
|
|
||||||
SUDO_USERS.remove(user_id)
|
SUDO_USERS.remove(user_id)
|
||||||
msg = 'Demoted'
|
msg = 'Demoted'
|
||||||
else:
|
else:
|
||||||
msg = 'Not a Sudo'
|
msg = 'Not a Sudo'
|
||||||
if DB_URI is None:
|
if DB_URI is None:
|
||||||
with open('authorized_chats.txt', 'a') as file:
|
|
||||||
file.truncate(0)
|
|
||||||
for i in AUTHORIZED_CHATS:
|
|
||||||
file.write(f'{i}\n')
|
|
||||||
with open('sudo_users.txt', 'a') as file:
|
with open('sudo_users.txt', 'a') as file:
|
||||||
file.truncate(0)
|
file.truncate(0)
|
||||||
for i in SUDO_USERS:
|
for i in SUDO_USERS:
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ from bot.helper.telegram_helper.message_utils import *
|
||||||
from bot.helper.telegram_helper.filters import CustomFilters
|
from bot.helper.telegram_helper.filters import CustomFilters
|
||||||
from bot.helper.telegram_helper.bot_commands import BotCommands
|
from bot.helper.telegram_helper.bot_commands import BotCommands
|
||||||
from bot.helper.mirror_utils.status_utils.clone_status import CloneStatus
|
from bot.helper.mirror_utils.status_utils.clone_status import CloneStatus
|
||||||
from bot import dispatcher, LOGGER, CLONE_LIMIT, STOP_DUPLICATE_CLONE, download_dict, download_dict_lock, Interval, DOWNLOAD_STATUS_UPDATE_INTERVAL
|
from bot import dispatcher, LOGGER, CLONE_LIMIT, STOP_DUPLICATE, download_dict, download_dict_lock, Interval, DOWNLOAD_STATUS_UPDATE_INTERVAL
|
||||||
from bot.helper.ext_utils.bot_utils import get_readable_file_size, setInterval
|
from bot.helper.ext_utils.bot_utils import get_readable_file_size, setInterval
|
||||||
import random
|
import random
|
||||||
import string
|
import string
|
||||||
|
|
@ -19,7 +19,7 @@ def cloneNode(update, context):
|
||||||
if res != "":
|
if res != "":
|
||||||
sendMessage(res, context.bot, update)
|
sendMessage(res, context.bot, update)
|
||||||
return
|
return
|
||||||
if STOP_DUPLICATE_CLONE:
|
if STOP_DUPLICATE:
|
||||||
LOGGER.info(f"Checking File/Folder if already in Drive...")
|
LOGGER.info(f"Checking File/Folder if already in Drive...")
|
||||||
smsg, button = gd.drive_list(name)
|
smsg, button = gd.drive_list(name)
|
||||||
if smsg:
|
if smsg:
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,7 @@ async def config_button(_, query):
|
||||||
elif data == '4':
|
elif data == '4':
|
||||||
return await query.message.edit(
|
return await query.message.edit(
|
||||||
__header__.format(data)
|
__header__.format(data)
|
||||||
+ f"**[ Stop Duplicate Config ]**\n\n**STOP_DUPLICATE_MIRROR:** `{STOP_DUPLICATE_MIRROR}`\n\n**STOP_DUPLICATE_CLONE:** `{STOP_DUPLICATE_CLONE}`\n\n**STOP_DUPLICATE_MEGA:** `{STOP_DUPLICATE_MEGA}`\n\n**[ Block Mega Config ]**\n\n**BLOCK_MEGA_FOLDER:** `{BLOCK_MEGA_FOLDER}`\n\n**BLOCK_MEGA_LINKS:** `{BLOCK_MEGA_LINKS}`",
|
+ f"**[ Stop/Block Config ]**\n\n**STOP_DUPLICATE** `{STOP_DUPLICATE}`\n\n**[ Block Mega Config ]**\n\n**BLOCK_MEGA_FOLDER:** `{BLOCK_MEGA_FOLDER}`\n\n**BLOCK_MEGA_LINKS:** `{BLOCK_MEGA_LINKS}`",
|
||||||
reply_markup=types.InlineKeyboardMarkup(
|
reply_markup=types.InlineKeyboardMarkup(
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
|
|
|
||||||
|
|
@ -27,9 +27,7 @@ MEGA_EMAIL_ID = ""
|
||||||
MEGA_PASSWORD = ""
|
MEGA_PASSWORD = ""
|
||||||
BLOCK_MEGA_FOLDER = ""
|
BLOCK_MEGA_FOLDER = ""
|
||||||
BLOCK_MEGA_LINKS = ""
|
BLOCK_MEGA_LINKS = ""
|
||||||
STOP_DUPLICATE_MIRROR = ""
|
STOP_DUPLICATE = ""
|
||||||
STOP_DUPLICATE_CLONE = ""
|
|
||||||
STOP_DUPLICATE_MEGA = ""
|
|
||||||
SHORTENER = ""
|
SHORTENER = ""
|
||||||
SHORTENER_API = ""
|
SHORTENER_API = ""
|
||||||
# If you want to use Credentials externally from Index Links, fill these vars with the direct links
|
# If you want to use Credentials externally from Index Links, fill these vars with the direct links
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue