revert
This commit is contained in:
parent
17db40150c
commit
8b970c2f84
|
|
@ -12,7 +12,7 @@
|
||||||

|

|
||||||
[](https://t.me/SlamMirrorSupport)
|
[](https://t.me/SlamMirrorSupport)
|
||||||
|
|
||||||
**Slam Mirror Bot** is a Telegram Bot writen in Python for mirroring files on the Internet to our beloved Google Drive.
|
**Slam Mirror Bot** is a multipurpose Telegram Bot writen in Python for mirroring files on the Internet to our beloved Google Drive.
|
||||||
|
|
||||||
# Features supported:
|
# Features supported:
|
||||||
|
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
- Multiple Trackers support
|
- Multiple Trackers support
|
||||||
- Check Heroku dynos stats
|
- Check Heroku dynos stats
|
||||||
- Custom image support
|
- Custom image support
|
||||||
- Counting file/folders
|
- Counting file/folder
|
||||||
- Racaty.net support
|
- Racaty.net support
|
||||||
- Shell and Executor
|
- Shell and Executor
|
||||||
- Stickers module
|
- Stickers module
|
||||||
|
|
|
||||||
|
|
@ -90,10 +90,10 @@ except:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
BOT_TOKEN = getConfig('BOT_TOKEN')
|
BOT_TOKEN = getConfig('BOT_TOKEN')
|
||||||
DB_URI = os.environ.get("DATABASE_URL")
|
DB_URI = getConfig('DATABASE_URL')
|
||||||
parent_id = getConfig('GDRIVE_FOLDER_ID')
|
parent_id = getConfig('GDRIVE_FOLDER_ID')
|
||||||
DOWNLOAD_DIR = getConfig('DOWNLOAD_DIR')
|
DOWNLOAD_DIR = getConfig('DOWNLOAD_DIR')
|
||||||
if not DOWNLOAD_DIR.endswith("/"):
|
if DOWNLOAD_DIR[-1] != '/' or DOWNLOAD_DIR[-1] != '\\':
|
||||||
DOWNLOAD_DIR = DOWNLOAD_DIR + '/'
|
DOWNLOAD_DIR = DOWNLOAD_DIR + '/'
|
||||||
DOWNLOAD_STATUS_UPDATE_INTERVAL = int(getConfig('DOWNLOAD_STATUS_UPDATE_INTERVAL'))
|
DOWNLOAD_STATUS_UPDATE_INTERVAL = int(getConfig('DOWNLOAD_STATUS_UPDATE_INTERVAL'))
|
||||||
OWNER_ID = int(getConfig('OWNER_ID'))
|
OWNER_ID = int(getConfig('OWNER_ID'))
|
||||||
|
|
@ -125,7 +125,8 @@ finally:
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
LOGGER.info("Generating USER_SESSION_STRING")
|
LOGGER.info("Generating USER_SESSION_STRING")
|
||||||
app = Client(':memory:', api_id=int(TELEGRAM_API), api_hash=TELEGRAM_HASH, bot_token=BOT_TOKEN)
|
with Client(':memory:', api_id=int(TELEGRAM_API), api_hash=TELEGRAM_HASH, bot_token=BOT_TOKEN) as app:
|
||||||
|
USER_SESSION_STRING = app.export_session_string()
|
||||||
|
|
||||||
#Generate Telegraph Token
|
#Generate Telegraph Token
|
||||||
sname = ''.join(random.SystemRandom().choices(string.ascii_letters, k=8))
|
sname = ''.join(random.SystemRandom().choices(string.ascii_letters, k=8))
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
import shutil, psutil
|
import shutil, psutil
|
||||||
import signal
|
import signal
|
||||||
import os
|
import pickle
|
||||||
|
|
||||||
from pyrogram import idle
|
from pyrogram import idle
|
||||||
from bot import app
|
from bot import app
|
||||||
|
from os import execl, kill, path, remove
|
||||||
from sys import executable
|
from sys import executable
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import pytz
|
import pytz
|
||||||
|
|
@ -11,7 +12,7 @@ import time
|
||||||
|
|
||||||
from telegram import ParseMode, BotCommand
|
from telegram import ParseMode, BotCommand
|
||||||
from telegram.ext import CommandHandler, run_async
|
from telegram.ext import CommandHandler, run_async
|
||||||
from bot import bot, dispatcher, updater, botStartTime, IMAGE_URL
|
from bot import dispatcher, updater, botStartTime, IMAGE_URL
|
||||||
from bot.helper.ext_utils import fs_utils
|
from bot.helper.ext_utils import fs_utils
|
||||||
from bot.helper.telegram_helper.bot_commands import BotCommands
|
from bot.helper.telegram_helper.bot_commands import BotCommands
|
||||||
from bot.helper.telegram_helper.message_utils import *
|
from bot.helper.telegram_helper.message_utils import *
|
||||||
|
|
@ -74,11 +75,10 @@ def restart(update, context):
|
||||||
restart_message = sendMessage("Restarting, Please wait!", context.bot, update)
|
restart_message = sendMessage("Restarting, Please wait!", context.bot, update)
|
||||||
LOGGER.info(f'Restarting the Bot...')
|
LOGGER.info(f'Restarting the Bot...')
|
||||||
# Save restart message object in order to reply to it after restarting
|
# Save restart message object in order to reply to it after restarting
|
||||||
with open(".restartmsg", "w") as f:
|
|
||||||
f.truncate(0)
|
|
||||||
f.write(f"{restart_message.chat.id}\n{restart_message.message_id}\n")
|
|
||||||
fs_utils.clean_all()
|
fs_utils.clean_all()
|
||||||
os.execl(executable, executable, "-m", "bot")
|
with open('restart.pickle', 'wb') as status:
|
||||||
|
pickle.dump(restart_message, status)
|
||||||
|
execl(executable, executable, "-m", "bot")
|
||||||
|
|
||||||
|
|
||||||
@run_async
|
@run_async
|
||||||
|
|
@ -197,29 +197,30 @@ BotCommand(f'{BotCommands.MirrorCommand}', 'Start Mirroring'),
|
||||||
BotCommand(f'{BotCommands.TarMirrorCommand}','Upload tar (zipped) file'),
|
BotCommand(f'{BotCommands.TarMirrorCommand}','Upload tar (zipped) file'),
|
||||||
BotCommand(f'{BotCommands.UnzipMirrorCommand}','Extract files'),
|
BotCommand(f'{BotCommands.UnzipMirrorCommand}','Extract files'),
|
||||||
BotCommand(f'{BotCommands.CloneCommand}','Copy file/folder to Drive'),
|
BotCommand(f'{BotCommands.CloneCommand}','Copy file/folder to Drive'),
|
||||||
BotCommand(f'{BotCommands.CountCommand}','Count file/folder of Drive Links'),
|
BotCommand(f'{BotCommands.CountCommand}','Count file/folder of Drive link'),
|
||||||
BotCommand(f'{BotCommands.WatchCommand}','Mirror YT-DL support link'),
|
BotCommand(f'{BotCommands.WatchCommand}','Mirror YT-DL support link'),
|
||||||
BotCommand(f'{BotCommands.TarWatchCommand}','Mirror Youtube playlist link as tar'),
|
BotCommand(f'{BotCommands.TarWatchCommand}','Mirror Youtube playlist link as tar'),
|
||||||
BotCommand(f'{BotCommands.CancelMirror}','Cancel a task'),
|
BotCommand(f'{BotCommands.CancelMirror}','Cancel a task'),
|
||||||
BotCommand(f'{BotCommands.CancelAllCommand}','Cancel all tasks'),
|
BotCommand(f'{BotCommands.CancelAllCommand}','Cancel all tasks'),
|
||||||
BotCommand(f'{BotCommands.DeleteCommand}','Delete file from Drive'),
|
BotCommand(f'{BotCommands.DeleteCommand}','Delete file from Drive'),
|
||||||
BotCommand(f'{BotCommands.ListCommand}',' [query] Searches files in G-Drive'),
|
BotCommand(f'{BotCommands.ListCommand}',' [query] Searches files in Drive'),
|
||||||
BotCommand(f'{BotCommands.StatusCommand}','Get Mirror Status message'),
|
BotCommand(f'{BotCommands.StatusCommand}','Get Mirror Status message'),
|
||||||
BotCommand(f'{BotCommands.StatsCommand}','Bot Usage Stats'),
|
BotCommand(f'{BotCommands.StatsCommand}','Bot Usage Stats'),
|
||||||
BotCommand(f'{BotCommands.HelpCommand}','Get Detailed Help'),
|
BotCommand(f'{BotCommands.HelpCommand}','Get Detailed Help'),
|
||||||
BotCommand(f'{BotCommands.SpeedCommand}','Check Speed of the host'),
|
BotCommand(f'{BotCommands.SpeedCommand}','Check Speed of the host'),
|
||||||
BotCommand(f'{BotCommands.LogCommand}','Bot Log [owner only]'),
|
BotCommand(f'{BotCommands.LogCommand}','Bot Log [owner/sudo only]'),
|
||||||
BotCommand(f'{BotCommands.RestartCommand}','Restart bot [owner only]')]
|
BotCommand(f'{BotCommands.RestartCommand}','Restart bot [owner/sudo only]')]
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
fs_utils.start_cleanup()
|
fs_utils.start_cleanup()
|
||||||
# Check if the bot is restarting
|
# Check if the bot is restarting
|
||||||
if os.path.isfile(".restartmsg"):
|
if path.exists('restart.pickle'):
|
||||||
with open(".restartmsg") as f:
|
with open('restart.pickle', 'rb') as status:
|
||||||
chat_id, msg_id = map(int, f)
|
restart_message = pickle.load(status)
|
||||||
bot.edit_message_text("Restarted successfully!", chat_id, msg_id)
|
restart_message.edit_text("Restarted Successfully!")
|
||||||
os.remove(".restartmsg")
|
LOGGER.info('Restarted Successfully!')
|
||||||
|
remove('restart.pickle')
|
||||||
|
|
||||||
bot.set_my_commands(botcmds)
|
bot.set_my_commands(botcmds)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,10 @@ import logging
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from bot import LOGGER, download_dict, download_dict_lock, app
|
from pyrogram import Client
|
||||||
|
|
||||||
|
from bot import LOGGER, download_dict, download_dict_lock, TELEGRAM_API, \
|
||||||
|
TELEGRAM_HASH, USER_SESSION_STRING
|
||||||
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
|
||||||
|
|
||||||
|
|
@ -20,7 +23,10 @@ class TelegramDownloadHelper(DownloadHelper):
|
||||||
self.__name = ""
|
self.__name = ""
|
||||||
self.__gid = ''
|
self.__gid = ''
|
||||||
self.__start_time = time.time()
|
self.__start_time = time.time()
|
||||||
self._bot = app
|
self._bot = Client(api_id=TELEGRAM_API,
|
||||||
|
api_hash=TELEGRAM_HASH,
|
||||||
|
session_name=USER_SESSION_STRING)
|
||||||
|
self._bot.start()
|
||||||
self.__is_cancelled = False
|
self.__is_cancelled = False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue