Fix duplicate upload

This commit is contained in:
Hafitz Setya 2021-06-20 08:50:08 +07:00 committed by GitHub
parent aa307f3845
commit 756df70487
Signed by untrusted user: GitHub
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 52 deletions

View File

@ -1,7 +1,6 @@
import shutil, psutil import shutil, psutil
import signal import signal
import os import os
import importlib
from pyrogram import idle from pyrogram import idle
from bot import app from bot import app
@ -19,11 +18,7 @@ from bot.helper.telegram_helper.message_utils import *
from .helper.ext_utils.bot_utils import get_readable_file_size, get_readable_time from .helper.ext_utils.bot_utils import get_readable_file_size, get_readable_time
from .helper.telegram_helper.filters import CustomFilters from .helper.telegram_helper.filters import CustomFilters
from bot.helper.telegram_helper import button_build from bot.helper.telegram_helper import button_build
from bot.modules import ALL_MODULES # Auto Load all modules without name problems from .modules import authorize, list, cancel_mirror, mirror_status, mirror, clone, watch, shell, eval, search, delete, speedtest, usage, mediainfo, count, config, updates
for module in ALL_MODULES:
imported_module = importlib.import_module("bot.modules." + module)
importlib.reload(imported_module)
now=datetime.now(pytz.timezone('Asia/Jakarta')) now=datetime.now(pytz.timezone('Asia/Jakarta'))

View File

@ -1,18 +1 @@
'''Methods Directory.'''
# Module folder for modules using Telegram.
# For easier development.
def __list_all_modules():
from os.path import dirname, basename, isfile
import glob
# This generates a list of modules in this folder for the * in __main__ to work.
mod_paths = glob.glob(dirname(__file__) + "/*.py")
return [
basename(f)[:-3] for f in mod_paths if isfile(f)
and f.endswith(".py")
and not f.endswith('__init__.py')
]
ALL_MODULES = sorted(__list_all_modules())
__all__ = ALL_MODULES + ["ALL_MODULES"]

View File

@ -1,11 +1,10 @@
# Implement by https://github.com/jusidama18 # Implement By https://github.com/jusidama18
# Based on this https://github.com/DevsExpo/FridayUserbot/blob/master/plugins/heroku_helpers.py # Based on this https://github.com/DevsExpo/FridayUserbot/blob/master/plugins/heroku_helpers.py
from pyrogram import filters, types, emoji from pyrogram import filters, types, emoji
from bot.helper.telegram_helper.bot_commands import BotCommands from bot.helper.telegram_helper.bot_commands import BotCommands
from bot import app, OWNER_ID from bot import app, OWNER_ID
from bot.helper import get_text, check_heroku from bot.helper import get_text, check_heroku
from bot.modules import ALL_MODULES
from bot import * from bot import *
# Add Variable # Add Variable
@ -54,7 +53,7 @@ __header__='📕 **Page** **{}**\n\n'
@app.on_message(filters.command(BotCommands.ConfigMenuCommand) & filters.user(OWNER_ID)) @app.on_message(filters.command(BotCommands.ConfigMenuCommand) & filters.user(OWNER_ID))
async def config_menu(_, message): async def config_menu(_, message):
await message.reply( await message.reply(
f"**Hello {message.from_user.mention}**,\n\n**If you want to add or set Variable in Heroku use** `/setvar`\n\n**If you want to delete Variable in Heroku use `/delvar`**\n\n**WARNING! Very Recommended to do this command in private since it's contain bot info.**\n\n**Here's This is Slam-MirrorBot Current Configs**\n\n\n", f"**Hello {message.from_user.mention}**,\n\n**If you want to add or set Variable in Heroku use** `/setvar`\n\n**If you want to delete Variable in Heroku use `/delvar`**\n\n**WARNING! Very Recommended to do this command in private since it's contain bot info.**\n\n**Here's This is Slam-MirrorBot Current Configs**",
reply_markup=types.InlineKeyboardMarkup( reply_markup=types.InlineKeyboardMarkup(
[[types.InlineKeyboardButton(f"{emoji.CROSS_MARK}", callback_data='docs_end'), types.InlineKeyboardButton(f"BOT CONFIG", callback_data='docs_1')]] [[types.InlineKeyboardButton(f"{emoji.CROSS_MARK}", callback_data='docs_end'), types.InlineKeyboardButton(f"BOT CONFIG", callback_data='docs_1')]]
) )
@ -66,11 +65,11 @@ async def config_button(_, query):
if data == '1': if data == '1':
return await query.message.edit( return await query.message.edit(
__header__.format(data) __header__.format(data)
+ f"**[ Telegram Config ]**\n\n**Bot Token:** `{BOT_TOKEN}`\n\n**Telegram API:** `{TELEGRAM_API}`\n\n**Telegram HASH:** `{TELEGRAM_HASH}`\n\n**Telegraph Token:** `{telegraph_token}`\n\n\n", + f"**[ Telegram Config ]**\n\n**Bot Token:** `{BOT_TOKEN}`\n\n**Telegram API:** `{TELEGRAM_API}`\n\n**Telegram HASH:** `{TELEGRAM_HASH}`\n\n**Telegraph Token:** `{telegraph_token}`",
reply_markup=types.InlineKeyboardMarkup( reply_markup=types.InlineKeyboardMarkup(
[ [
[ [
types.InlineKeyboardButton(f"{emoji.LEFT_ARROW}", callback_data='docs_10'), types.InlineKeyboardButton(f"{emoji.LEFT_ARROW}", callback_data='docs_9'),
types.InlineKeyboardButton(f"{emoji.CROSS_MARK}", callback_data='docs_end'), types.InlineKeyboardButton(f"{emoji.CROSS_MARK}", callback_data='docs_end'),
types.InlineKeyboardButton(f"{emoji.RIGHT_ARROW}", callback_data='docs_2') types.InlineKeyboardButton(f"{emoji.RIGHT_ARROW}", callback_data='docs_2')
] ]
@ -80,7 +79,7 @@ async def config_button(_, query):
elif data == '2': elif data == '2':
return await query.message.edit( return await query.message.edit(
__header__.format(data) __header__.format(data)
+ f"**[ Drive and Index Config ]**\n**Drive Folder:** `{parent_id}`\n\n**Using Team Drive:** `{IS_TEAM_DRIVE}`\n\n**Using Service Account:** `{USE_SERVICE_ACCOUNTS}`\n\n**Index Url:** `{INDEX_URL}`\n\n\n", + f"**[ Drive and Index Config ]**\n**Drive Folder:** `{parent_id}`\n\n**Using Team Drive:** `{IS_TEAM_DRIVE}`\n\n**Using Service Account:** `{USE_SERVICE_ACCOUNTS}`\n\n**Index Url:** `{INDEX_URL}`",
reply_markup=types.InlineKeyboardMarkup( reply_markup=types.InlineKeyboardMarkup(
[ [
[ [
@ -94,7 +93,7 @@ async def config_button(_, query):
elif data == '3': elif data == '3':
return await query.message.edit( return await query.message.edit(
__header__.format(data) __header__.format(data)
+ f"**[ Mega and Uptobox Config ]**\n\n**Mega API:** `{MEGA_API_KEY}`\n\n**Mega Email:** `{MEGA_EMAIL_ID}`\n\n**Mega Password:** `{MEGA_PASSWORD}`\n\n**Uptobox Token:** `{UPTOBOX_TOKEN}`\n\n\n", + f"**[ Mega and Uptobox Config ]**\n\n**Mega API:** `{MEGA_API_KEY}`\n\n**Mega Email:** `{MEGA_EMAIL_ID}`\n\n**Mega Password:** `{MEGA_PASSWORD}`\n\n**Uptobox Token:** `{UPTOBOX_TOKEN}`",
reply_markup=types.InlineKeyboardMarkup( reply_markup=types.InlineKeyboardMarkup(
[ [
[ [
@ -108,7 +107,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**Mirror:** `{STOP_DUPLICATE_MIRROR}`\n\n**Clone:** `{STOP_DUPLICATE_CLONE}`\n\n**Mega:** `{STOP_DUPLICATE_MEGA}`\n\n**[ Block Mega Config ]**\n\n**Folder:** `{BLOCK_MEGA_FOLDER}`\n\n**Link:** `{BLOCK_MEGA_LINKS}`\n\n\n", + f"**[ Stop Duplicate Config ]**\n\n**Mirror:** `{STOP_DUPLICATE_MIRROR}`\n\n**Clone:** `{STOP_DUPLICATE_CLONE}`\n\n**Mega:** `{STOP_DUPLICATE_MEGA}`\n\n**[ Block Mega Config ]**\n\n**Folder:** `{BLOCK_MEGA_FOLDER}`\n\n**Link:** `{BLOCK_MEGA_LINKS}`\n\n",
reply_markup=types.InlineKeyboardMarkup( reply_markup=types.InlineKeyboardMarkup(
[ [
[ [
@ -122,7 +121,7 @@ async def config_button(_, query):
elif data == '5': elif data == '5':
return await query.message.edit( return await query.message.edit(
__header__.format(data) __header__.format(data)
+ f"**[ Limit Size Config ]**\n\n**Torrent and Direct:** `{TORRENT_DIRECT_LIMIT}`\n\n**Clone:** `{CLONE_LIMIT}`\n\n**Mega:** `{MEGA_LIMIT}`\n\n\n", + f"**[ Limit Size Config ]**\n\n**Torrent and Direct:** `{TORRENT_DIRECT_LIMIT}`\n\n**Clone:** `{CLONE_LIMIT}`\n\n**Mega:** `{MEGA_LIMIT}`",
reply_markup=types.InlineKeyboardMarkup( reply_markup=types.InlineKeyboardMarkup(
[ [
[ [
@ -139,7 +138,7 @@ async def config_button(_, query):
sudo += '\n'.join(str(id) for id in SUDO_USERS) sudo += '\n'.join(str(id) for id in SUDO_USERS)
return await query.message.edit( return await query.message.edit(
__header__.format(data) __header__.format(data)
+ f"**[ User ID Config ]**\n\n**Owner ID:** `{OWNER_ID}`\n\n**Authorized Chat:**\n`{user}`\n\n**Sudo Users:**\n`{sudo}`\n\n\n", + f"**[ User ID Config ]**\n\n**Owner ID:** `{OWNER_ID}`\n\n**Authorized Chat:**\n`{user}`\n\n**Sudo Users:**\n`{sudo}`",
reply_markup=types.InlineKeyboardMarkup( reply_markup=types.InlineKeyboardMarkup(
[ [
[ [
@ -153,7 +152,7 @@ async def config_button(_, query):
elif data == '7': elif data == '7':
return await query.message.edit( return await query.message.edit(
__header__.format(data) __header__.format(data)
+ f"**[ Button Config ]**\n\n**Button Four Name:** `{BUTTON_FOUR_NAME}`\n\n**Button Four Url:** `{BUTTON_FOUR_URL}`\n\n**Button Five Name:** `{BUTTON_FIVE_NAME}`\n\n**Button Five Url:** `{BUTTON_FIVE_URL}`\n\n**Button Six Name:** `{BUTTON_SIX_NAME}`\n\n**Button Six Url:** `{BUTTON_SIX_URL}`\n\n\n", + f"**[ Button Config ]**\n\n**Button Four Name:** `{BUTTON_FOUR_NAME}`\n\n**Button Four Url:** `{BUTTON_FOUR_URL}`\n\n**Button Five Name:** `{BUTTON_FIVE_NAME}`\n\n**Button Five Url:** `{BUTTON_FIVE_URL}`\n\n**Button Six Name:** `{BUTTON_SIX_NAME}`\n\n**Button Six Url:** `{BUTTON_SIX_URL}`",
reply_markup=types.InlineKeyboardMarkup( reply_markup=types.InlineKeyboardMarkup(
[ [
[ [
@ -167,7 +166,7 @@ async def config_button(_, query):
elif data == '8': elif data == '8':
return await query.message.edit( return await query.message.edit(
__header__.format(data) __header__.format(data)
+ f"**[ Heroku Config ]**\n\n**Heroku Name:** `{HEROKU_APP_NAME}`\n\n**Heroku API:** `{HEROKU_API_KEY}`\n\n**[ Upstream Config ]**\n\n**Upstream Repo :** `{UPSTREAM_REPO}`\n\n**Upstream Branch :** `{UPSTREAM_BRANCH}`\n\n**[ Shortener Config ]**\n\n**Shortener Name:** `{SHORTENER}`\n\n**Shortener API:** `{SHORTENER_API}`\n\n\n", + f"**[ Heroku Config ]**\n\n**Heroku Name:** `{HEROKU_APP_NAME}`\n\n**Heroku API:** `{HEROKU_API_KEY}`\n\n**[ Shortener Config ]**\n\n**Shortener Name:** `{SHORTENER}`\n\n**Shortener API:** `{SHORTENER_API}`",
reply_markup=types.InlineKeyboardMarkup( reply_markup=types.InlineKeyboardMarkup(
[ [
[ [
@ -181,26 +180,12 @@ async def config_button(_, query):
elif data == '9': elif data == '9':
return await query.message.edit( return await query.message.edit(
__header__.format(data) __header__.format(data)
+ f" **[ Others Config ]**\n\n**Ignore Pending Request:** `{IGNORE_PENDING_REQUESTS}`\n\n**Image Url:** `{IMAGE_URL}`\n\n**Directory:** `{DOWNLOAD_DIR}`\n\n**Status Interval:** `{DOWNLOAD_STATUS_UPDATE_INTERVAL}`\n\n**View Link:** `{VIEW_LINK}`\n\n**Database Url:** `{DB_URI}`\n\n**Delete Message Duration:** `{AUTO_DELETE_MESSAGE_DURATION}`\n\n\n", + f" **[ Others Config ]**\n\n**Ignore Pending Request:** `{IGNORE_PENDING_REQUESTS}`\n\n**Image Url:** `{IMAGE_URL}`\n\n**Directory:** `{DOWNLOAD_DIR}`\n\n**Status Interval:** `{DOWNLOAD_STATUS_UPDATE_INTERVAL}`\n\n**View Link:** `{VIEW_LINK}`\n\n**Database Url:** `{DB_URI}`\n\n**Delete Message Duration:** `{AUTO_DELETE_MESSAGE_DURATION}`",
reply_markup=types.InlineKeyboardMarkup( reply_markup=types.InlineKeyboardMarkup(
[ [
[ [
types.InlineKeyboardButton(f"{emoji.LEFT_ARROW}", callback_data='docs_8'), types.InlineKeyboardButton(f"{emoji.LEFT_ARROW}", callback_data='docs_8'),
types.InlineKeyboardButton(f"{emoji.CROSS_MARK}", callback_data='docs_end'), types.InlineKeyboardButton(f"{emoji.CROSS_MARK}", callback_data='docs_end'),
types.InlineKeyboardButton(f"{emoji.RIGHT_ARROW}", callback_data='docs_10')
]
]
)
)
elif data == '10':
return await query.message.edit(
__header__.format(data)
+ f" **[ Module Config ]**\n\n**All Module:** \n`{ALL_MODULES}`\n\n\n",
reply_markup=types.InlineKeyboardMarkup(
[
[
types.InlineKeyboardButton(f"{emoji.LEFT_ARROW}", callback_data='docs_9'),
types.InlineKeyboardButton(f"{emoji.CROSS_MARK}", callback_data='docs_end'),
types.InlineKeyboardButton(f"{emoji.RIGHT_ARROW}", callback_data='docs_1') types.InlineKeyboardButton(f"{emoji.RIGHT_ARROW}", callback_data='docs_1')
] ]
] ]

View File

@ -302,7 +302,7 @@ def _mirror(bot, update, isTar=False, extract=False):
if bot_utils.is_gdrive_link(link): if bot_utils.is_gdrive_link(link):
if not isTar and not extract: if not isTar and not extract:
sendMessage(f"Use /{BotCommands.CloneCommand} To Copy File/Folder", bot, update) sendMessage(f"Use /{BotCommands.CloneCommand} To Copy Google Drive File/Folder", bot, update)
return return
res, size, name = gdriveTools.GoogleDriveHelper().clonehelper(link) res, size, name = gdriveTools.GoogleDriveHelper().clonehelper(link)
if res != "": if res != "":

View File

@ -1,4 +1,4 @@
# Implement by https://github.com/jusidama18 # Implement By https://github.com/jusidama18
# Based on this https://github.com/DevsExpo/FridayUserbot/blob/master/plugins/updater.py # Based on this https://github.com/DevsExpo/FridayUserbot/blob/master/plugins/updater.py
import sys import sys