v4.7.3
- Auto set bot command - Added mediainfo command Co-authored-by: brutewooorse <brutewooorse@users.noreply.github.com> Co-authored-by: code-rgb <code-rgb@users.noreply.github.com>
This commit is contained in:
parent
7dd2997586
commit
8b39987d69
|
|
@ -8,7 +8,7 @@ RUN apt-get -qq update && \
|
||||||
rm -rf /var/lib/apt/lists/* && \
|
rm -rf /var/lib/apt/lists/* && \
|
||||||
apt-add-repository non-free && \
|
apt-add-repository non-free && \
|
||||||
apt-get -qq update && \
|
apt-get -qq update && \
|
||||||
apt-get -qq install -y p7zip-full p7zip-rar aria2 curl pv jq ffmpeg locales python3-lxml && \
|
apt-get -qq install -y p7zip-full mediainfo p7zip-rar aria2 curl pv jq ffmpeg locales python3-lxml && \
|
||||||
apt-get purge -y software-properties-common
|
apt-get purge -y software-properties-common
|
||||||
|
|
||||||
COPY requirements.txt .
|
COPY requirements.txt .
|
||||||
|
|
|
||||||
24
README.md
24
README.md
|
|
@ -7,6 +7,7 @@ This is a Telegram bot writen in Python for mirroring files on the Internet to o
|
||||||
|
|
||||||
## Additional Features
|
## Additional Features
|
||||||
- Mirroring Uptobox.com links to Google Drive (Uptobox account must be premium)
|
- Mirroring Uptobox.com links to Google Drive (Uptobox account must be premium)
|
||||||
|
- Get detailed info about replied media
|
||||||
- Nyaa.si and Sukebei Torrent search
|
- Nyaa.si and Sukebei Torrent search
|
||||||
- Speedtest with picture results
|
- Speedtest with picture results
|
||||||
- Limiting Torrent size support
|
- Limiting Torrent size support
|
||||||
|
|
@ -16,7 +17,7 @@ This is a Telegram bot writen in Python for mirroring files on the Internet to o
|
||||||
- Shell and Executor
|
- Shell and Executor
|
||||||
- Stickers module
|
- Stickers module
|
||||||
|
|
||||||
## From Source Repos
|
## From Original Repos
|
||||||
- Mirroring direct download links, Torrent, and Telegram files to Google Drive
|
- Mirroring direct download links, Torrent, and Telegram files to Google Drive
|
||||||
- Mirroring Mega.nz links to Google Drive (If your Mega account not premium, it will limit 4-5gb/day)
|
- Mirroring Mega.nz links to Google Drive (If your Mega account not premium, it will limit 4-5gb/day)
|
||||||
- Copy files from someone's Drive to your Drive (Using Autorclone)
|
- Copy files from someone's Drive to your Drive (Using Autorclone)
|
||||||
|
|
@ -156,27 +157,6 @@ sudo docker run mirrorbot
|
||||||
## Deploying on Heroku with heroku-cli and Goorm IDE
|
## Deploying on Heroku with heroku-cli and Goorm IDE
|
||||||
<p><a href="https://telegra.ph/How-to-Deploy-a-Mirror-Bot-to-Heroku-with-CLI-05-06"> <img src="https://img.shields.io/badge/see%20on%20telegraph-grey?style=for-the-badge" width="190""/></a></p>
|
<p><a href="https://telegra.ph/How-to-Deploy-a-Mirror-Bot-to-Heroku-with-CLI-05-06"> <img src="https://img.shields.io/badge/see%20on%20telegraph-grey?style=for-the-badge" width="190""/></a></p>
|
||||||
|
|
||||||
## Bot commands to be set in [@BotFather](https://t.me/BotFather)
|
|
||||||
|
|
||||||
```
|
|
||||||
mirror - Start Mirroring
|
|
||||||
tarmirror - Upload tar (zipped) file
|
|
||||||
unzipmirror - Extract files
|
|
||||||
clone - Copy file/folder to Drive
|
|
||||||
watch - Mirror YT-DL support link
|
|
||||||
tarwatch - Mirror Youtube playlist link as tar
|
|
||||||
cancel - Cancel a task
|
|
||||||
cancelall - Cancel all tasks
|
|
||||||
del - Delete file from Drive
|
|
||||||
list - [query] Searches files in G-Drive
|
|
||||||
status - Get Mirror Status message
|
|
||||||
stats - Bot Usage Stats
|
|
||||||
help - Get Detailed Help
|
|
||||||
speedtest - Check Speed of the host
|
|
||||||
log - Bot Log [owner only]
|
|
||||||
restart - restart bot [owner only]
|
|
||||||
repo - Get the bot repo
|
|
||||||
```
|
|
||||||
|
|
||||||
## Using Service Accounts for uploading to avoid user rate limit
|
## Using Service Accounts for uploading to avoid user rate limit
|
||||||
For Service Account to work, you must set **USE_SERVICE_ACCOUNTS=**"True" in config file or environment variables,
|
For Service Account to work, you must set **USE_SERVICE_ACCOUNTS=**"True" in config file or environment variables,
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ from sys import executable
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import pytz
|
import pytz
|
||||||
import time
|
import time
|
||||||
from telegram import ParseMode, InlineKeyboardMarkup, InlineKeyboardButton
|
from telegram import ParseMode, BotCommand, InlineKeyboardMarkup, InlineKeyboardButton
|
||||||
from telegram.ext import CommandHandler, run_async
|
from telegram.ext import CommandHandler, run_async
|
||||||
from bot import dispatcher, updater, botStartTime, AUTHORIZED_CHATS, IMAGE_URL
|
from bot import dispatcher, updater, botStartTime, AUTHORIZED_CHATS, IMAGE_URL
|
||||||
from bot.helper.ext_utils import fs_utils
|
from bot.helper.ext_utils import fs_utils
|
||||||
|
|
@ -16,7 +16,7 @@ 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 *
|
||||||
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 .modules import authorize, list, cancel_mirror, mirror_status, mirror, clone, watch, shell, eval, anime, stickers, search, delete, speedtest, usage
|
from .modules import authorize, list, cancel_mirror, mirror_status, mirror, clone, watch, shell, eval, anime, stickers, search, delete, speedtest, usage, mediainfo
|
||||||
|
|
||||||
now=datetime.now(pytz.timezone('Asia/Jakarta'))
|
now=datetime.now(pytz.timezone('Asia/Jakarta'))
|
||||||
|
|
||||||
|
|
@ -133,6 +133,8 @@ def bot_help(update, context):
|
||||||
|
|
||||||
/{BotCommands.RepoCommand}: Get the bot repo.
|
/{BotCommands.RepoCommand}: Get the bot repo.
|
||||||
|
|
||||||
|
/mediainfo: Get detailed info about replied media.
|
||||||
|
|
||||||
/tshelp: Get help for Torrent search module.
|
/tshelp: Get help for Torrent search module.
|
||||||
|
|
||||||
/weebhelp: Get help for Anime, Manga, and Character module.
|
/weebhelp: Get help for Anime, Manga, and Character module.
|
||||||
|
|
@ -142,6 +144,26 @@ def bot_help(update, context):
|
||||||
sendMessage(help_string, context.bot, update)
|
sendMessage(help_string, context.bot, update)
|
||||||
|
|
||||||
|
|
||||||
|
botcmds = [
|
||||||
|
BotCommand(f'{BotCommands.MirrorCommand}', 'Start Mirroring'),
|
||||||
|
BotCommand(f'{BotCommands.TarMirrorCommand}','Upload tar (zipped) file'),
|
||||||
|
BotCommand(f'{BotCommands.UnzipMirrorCommand}','Extract files'),
|
||||||
|
BotCommand(f'{BotCommands.CloneCommand}','Copy file/folder to Drive'),
|
||||||
|
BotCommand(f'{BotCommands.WatchCommand}','Mirror YT-DL support link'),
|
||||||
|
BotCommand(f'{BotCommands.TarWatchCommand}','Mirror Youtube playlist link as tar'),
|
||||||
|
BotCommand(f'{BotCommands.CancelMirror}','Cancel a task'),
|
||||||
|
BotCommand(f'{BotCommands.CancelAllCommand}','Cancel all tasks'),
|
||||||
|
BotCommand(f'{BotCommands.DeleteCommand}','Delete file from Drive'),
|
||||||
|
BotCommand(f'{BotCommands.ListCommand}',' [query] Searches files in G-Drive'),
|
||||||
|
BotCommand(f'{BotCommands.StatusCommand}','Get Mirror Status message'),
|
||||||
|
BotCommand(f'{BotCommands.StatsCommand}','Bot Usage Stats'),
|
||||||
|
BotCommand(f'{BotCommands.HelpCommand}','Get Detailed Help'),
|
||||||
|
BotCommand(f'{BotCommands.SpeedCommand}','Check Speed of the host'),
|
||||||
|
BotCommand(f'{BotCommands.LogCommand}','Bot Log [owner only]'),
|
||||||
|
BotCommand(f'{BotCommands.RestartCommand}','Restart bot [owner only]'),
|
||||||
|
BotCommand(f'{BotCommands.RepoCommand}','Get the bot repo')]
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
fs_utils.start_cleanup()
|
fs_utils.start_cleanup()
|
||||||
# Check if the bot is restarting
|
# Check if the bot is restarting
|
||||||
|
|
@ -151,6 +173,7 @@ def main():
|
||||||
restart_message.edit_text("Restarted Successfully!")
|
restart_message.edit_text("Restarted Successfully!")
|
||||||
LOGGER.info('Restarted Successfully!')
|
LOGGER.info('Restarted Successfully!')
|
||||||
remove('restart.pickle')
|
remove('restart.pickle')
|
||||||
|
bot.set_my_commands(botcmds)
|
||||||
|
|
||||||
start_handler = CommandHandler(BotCommands.StartCommand, start,
|
start_handler = CommandHandler(BotCommands.StartCommand, start,
|
||||||
filters=CustomFilters.authorized_chat | CustomFilters.authorized_user)
|
filters=CustomFilters.authorized_chat | CustomFilters.authorized_user)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
import asyncio
|
||||||
|
import os
|
||||||
|
import shlex
|
||||||
|
from typing import Tuple
|
||||||
|
from html_telegraph_poster import TelegraphPoster
|
||||||
|
|
||||||
|
def post_to_telegraph(a_title: str, content: str) -> str:
|
||||||
|
""" Create a Telegram Post using HTML Content """
|
||||||
|
post_client = TelegraphPoster(use_api=True)
|
||||||
|
auth_name = "slam-mirrorbot"
|
||||||
|
post_client.create_api_token(auth_name)
|
||||||
|
post_page = post_client.post(
|
||||||
|
title=a_title,
|
||||||
|
author=auth_name,
|
||||||
|
author_url="https://github.com/breakdowns/slam-mirrorbot",
|
||||||
|
text=content,
|
||||||
|
)
|
||||||
|
return post_page["url"]
|
||||||
|
|
||||||
|
|
||||||
|
async def runcmd(cmd: str) -> Tuple[str, str, int, int]:
|
||||||
|
""" run command in terminal """
|
||||||
|
args = shlex.split(cmd)
|
||||||
|
process = await asyncio.create_subprocess_exec(
|
||||||
|
*args, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE
|
||||||
|
)
|
||||||
|
stdout, stderr = await process.communicate()
|
||||||
|
return (
|
||||||
|
stdout.decode("utf-8", "replace").strip(),
|
||||||
|
stderr.decode("utf-8", "replace").strip(),
|
||||||
|
process.returncode,
|
||||||
|
process.pid,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# Solves ValueError: No closing quotation by removing ' or " in file name
|
||||||
|
def safe_filename(path_):
|
||||||
|
if path_ is None:
|
||||||
|
return
|
||||||
|
safename = path_.replace("'", "").replace('"', "")
|
||||||
|
if safename != path_:
|
||||||
|
os.rename(path_, safename)
|
||||||
|
return safename
|
||||||
|
|
@ -0,0 +1,54 @@
|
||||||
|
# Suggested by - @d0n0t (https://github.com/code-rgb/USERGE-X/issues/9)
|
||||||
|
# Copyright (C) 2020 BY - GitHub.com/code-rgb [TG - @deleteduser420]
|
||||||
|
# All rights reserved.
|
||||||
|
|
||||||
|
import os
|
||||||
|
from pyrogram import filters
|
||||||
|
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup
|
||||||
|
from bot import app
|
||||||
|
from bot.helper import post_to_telegraph, runcmd, safe_filename
|
||||||
|
|
||||||
|
@app.on_message(filters.command(['mediainfo']))
|
||||||
|
async def mediainfo(client, message):
|
||||||
|
reply = message.reply_to_message
|
||||||
|
if not reply:
|
||||||
|
await message.reply_text("Reply to Media first")
|
||||||
|
return
|
||||||
|
process = await message.reply_text("`Processing...`")
|
||||||
|
x_media = None
|
||||||
|
available_media = (
|
||||||
|
"audio",
|
||||||
|
"document",
|
||||||
|
"photo",
|
||||||
|
"sticker",
|
||||||
|
"animation",
|
||||||
|
"video",
|
||||||
|
"voice",
|
||||||
|
"video_note",
|
||||||
|
"new_chat_photo",
|
||||||
|
)
|
||||||
|
for kind in available_media:
|
||||||
|
x_media = getattr(reply, kind, None)
|
||||||
|
if x_media is not None:
|
||||||
|
break
|
||||||
|
if x_media is None:
|
||||||
|
await process.edit_text("Reply To a Valid Media Format")
|
||||||
|
return
|
||||||
|
media_type = str(type(x_media)).split("'")[1]
|
||||||
|
file_path = safe_filename(await reply.download())
|
||||||
|
output_ = await runcmd(f'mediainfo "{file_path}"')
|
||||||
|
out = None
|
||||||
|
if len(output_) != 0:
|
||||||
|
out = output_[0]
|
||||||
|
body_text = f"""
|
||||||
|
<h2>JSON</h2>
|
||||||
|
<pre>{x_media}</pre>
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<h2>DETAILS</h2>
|
||||||
|
<pre>{out or 'Not Supported'}</pre>
|
||||||
|
"""
|
||||||
|
text_ = media_type.split(".")[-1].upper()
|
||||||
|
link = post_to_telegraph(media_type, body_text)
|
||||||
|
markup = InlineKeyboardMarkup([[InlineKeyboardButton(text=text_, url=link)]])
|
||||||
|
await process.edit_text("ℹ️ <b>MEDIA INFO</b>", reply_markup=markup)
|
||||||
|
|
@ -28,7 +28,7 @@ IMAGE_URL = "https://telegra.ph/file/db03910496f06094f1f7a.jpg"
|
||||||
# Change ENABLE_FILESIZE_LIMIT = True if you want to use MAX_TORRENT_SIZE
|
# Change ENABLE_FILESIZE_LIMIT = True if you want to use MAX_TORRENT_SIZE
|
||||||
ENABLE_FILESIZE_LIMIT = false
|
ENABLE_FILESIZE_LIMIT = false
|
||||||
MAX_TORRENT_SIZE = 15
|
MAX_TORRENT_SIZE = 15
|
||||||
# Fill only if you deploying on heroku-cli
|
# Fill only if you deploying with heroku-cli and Goorm IDE
|
||||||
HEROKU_API_KEY = ""
|
HEROKU_API_KEY = ""
|
||||||
HEROKU_APP_NAME = ""
|
HEROKU_APP_NAME = ""
|
||||||
# Add more buttons (two buttons are already added of file link and index link, you can add extra buttons too, these are optional)
|
# Add more buttons (two buttons are already added of file link and index link, you can add extra buttons too, these are optional)
|
||||||
|
|
|
||||||
|
|
@ -24,3 +24,4 @@ js2py
|
||||||
lxml
|
lxml
|
||||||
telegraph
|
telegraph
|
||||||
pytz
|
pytz
|
||||||
|
html-telegraph-poster>=0.2.31
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue