Skip to content

Commit

Permalink
v4.8.7 (breakdowns#221)
Browse files Browse the repository at this point in the history
- Add mediainfo & shell custom command
- Add Set Variable, Delete Variable, and Bot Info Menu (Only for Heroku)
- Add Updater for update Bot from upstream (Only for Heroku)
- Auto Load Modules
- Torrent Search: Add 1337x, piratebay, tgx, yts, eztv, torlock, rarbg support


Co-authored-by: Anas <[email protected]>
Co-authored-by: Juan <[email protected]>
Co-authored-by: Arsalan <[email protected]>
Co-authored-by: xd003 <[email protected]>
Signed-off-by: breakdowns <[email protected]>
  • Loading branch information
5 people authored Jun 19, 2021
1 parent d2173c9 commit 57d9e5a
Show file tree
Hide file tree
Showing 15 changed files with 434 additions and 10 deletions.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,25 @@
# Features supported:
## Additional Features
- Get detailed info about replied media (Only for Telegram file)
- Nyaa.si and Sukebei Torrent search
- Speedtest with picture results
- Stop duplicate cloning Google Drive & mirroring Mega support
- Limiting size Torrent/Direct, Mega, cloning Google Drive support
- Sudo with Database support
- Multiple Trackers support
- Check Heroku dynos stats
- Heroku config support
- Updater (Only for Heroku)
- Extracting **tar.xz** support
- Create Tar Google Drive folder
- Custom image support
- Counting file/folder
- Shell and Executor
- View Link button
- Torrent search supported:
```
nyaa, sukebei, 1337x, piratebay, tgx,
yts, eztv, torlock, rarbg
```
- Direct links supported:
```
letsupload.io, hxfile.co, anonfiles.com, fembed.com, femax20.com, layarkacaxxi.icu,
Expand Down Expand Up @@ -129,6 +136,8 @@ Fill up rest of the fields. Meaning of each fields are discussed below:
- **DOWNLOAD_DIR**: The path to the local folder where the downloads should be downloaded to
- **DOWNLOAD_STATUS_UPDATE_INTERVAL**: A short interval of time in seconds after which the Mirror progress message is updated. (I recommend to keep it `5` seconds at least)
- **AUTO_DELETE_MESSAGE_DURATION**: Interval of time (in seconds), after which the bot deletes it's message (and command message) which is expected to be viewed instantly. (**Note**: Set to `-1` to never automatically delete messages)
- **UPSTREAM_REPO**: Link for Bot Upstream Repo, if you want default update, fill ```https://github.com/breakdowns/slam-mirrorbot```.
- **UPSTREAM_BRANCH**: Link for Bot Upstream Repo (Recommended using master branch)
### Optional Field
- **AUTHORIZED_CHATS**: Fill user_id and chat_id of you want to authorize.
- **IS_TEAM_DRIVE**: Set to `True` if `GDRIVE_FOLDER_ID` is from a Team Drive else `False` or Leave it empty.
Expand Down
10 changes: 10 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@
"description": "Add the Heroku app name here.",
"required": true
},
"UPSTREAM_REPO": {
"description": "Link for Bot Upstream Repo, If you want default update, Fill https://github.com/breakdowns/slam-mirrorbot.",
"value": "https://github.com/breakdowns/slam-mirrorbot",
"required": true
},
"UPSTREAM_BRANCH": {
"description": "Branch name for Upstream Repo (Recommended using master branch).",
"value": "master",
"required": true
},
"UPTOBOX_TOKEN": {
"description": "Uptobox premium token to mirror uptobox links. Get it from https://uptobox.com/my_account.",
"required": false
Expand Down
2 changes: 2 additions & 0 deletions bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ def mktable():
AUTO_DELETE_MESSAGE_DURATION = int(getConfig('AUTO_DELETE_MESSAGE_DURATION'))
TELEGRAM_API = getConfig('TELEGRAM_API')
TELEGRAM_HASH = getConfig('TELEGRAM_HASH')
UPSTREAM_REPO = getConfig('UPSTREAM_REPO')
UPSTREAM_BRANCH = getConfig('UPSTREAM_BRANCH')
except KeyError as e:
LOGGER.error("One or more env variables missing! Exiting now")
exit(1)
Expand Down
18 changes: 14 additions & 4 deletions bot/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import shutil, psutil
import signal
import os
import importlib

from pyrogram import idle
from bot import app
Expand All @@ -18,7 +19,11 @@
from .helper.ext_utils.bot_utils import get_readable_file_size, get_readable_time
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, search, delete, speedtest, usage, mediainfo, count
from bot.modules import ALL_MODULES # Auto Load all modules without name problems

for module in ALL_MODULES:
imported_module = importlib.import_module("bot.modules." + module)
importlib.reload(imported_module)

now=datetime.now(pytz.timezone('Asia/Jakarta'))

Expand Down Expand Up @@ -129,13 +134,17 @@ def bot_help(update, context):
/{BotCommands.LogCommand}: Get a log file of the bot. Handy for getting crash reports
/{BotCommands.ConfigMenuCommand}: Get Info Menu about bot config (Owner Only).
/{BotCommands.UpdateCommand}: Update Bot from Upstream Repo. (Owner Only).
/{BotCommands.UsageCommand}: To see Heroku Dyno Stats (Owner & Sudo only).
/{BotCommands.SpeedCommand}: Check Internet Speed of the Host
/shell: Run commands in Shell (Terminal).
/{BotCommands.MediaInfoCommand}: Get detailed info about replied media (Only for Telegram file).
/mediainfo: Get detailed info about replied media (Only for Telegram file).
/{BotCommands.ShellCommand}: Run commands in Shell (Terminal).
/tshelp: Get help for Torrent search module.
'''
Expand Down Expand Up @@ -167,7 +176,7 @@ def bot_help(update, context):
/{BotCommands.SpeedCommand}: Check Internet Speed of the Host
/mediainfo: Get detailed info about replied media (Only for Telegram file).
/{BotCommands.MediaInfoCommand}: Get detailed info about replied media (Only for Telegram file).
/tshelp: Get help for Torrent search module.
'''
Expand All @@ -193,6 +202,7 @@ def bot_help(update, context):
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.MediaInfoCommand}','Get detailed info about replied media'),
BotCommand(f'{BotCommands.SpeedCommand}','Check Speed of the host'),
BotCommand(f'{BotCommands.LogCommand}','Bot Log [owner/sudo only]'),
BotCommand(f'{BotCommands.RestartCommand}','Restart bot [owner/sudo only]')]
Expand Down
70 changes: 70 additions & 0 deletions bot/helper/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,78 @@
import asyncio
import os
import shlex
import heroku3

from functools import wraps
from pyrogram.types import Message
from typing import Tuple
from html_telegraph_poster import TelegraphPoster
from bot import HEROKU_API_KEY, HEROKU_APP_NAME

# Implement by https://github.com/jusidama18
# Setting Message

def get_text(message: Message) -> [None, str]:
"""Extract Text From Commands"""
text_to_return = message.text
if message.text is None:
return None
if " " in text_to_return:
try:
return message.text.split(None, 1)[1]
except IndexError:
return None
else:
return None

# Preparing For Setting Config
# Implement by https://github.com/jusidama18 and Based on this https://github.com/DevsExpo/FridayUserbot/blob/master/plugins/heroku_helpers.py

heroku_client = None
if HEROKU_API_KEY:
heroku_client = heroku3.from_key(HEROKU_API_KEY)

def check_heroku(func):
@wraps(func)
async def heroku_cli(client, message):
heroku_app = None
if not heroku_client:
await message.reply_text("`Please Add HEROKU_API_KEY Key For This To Function To Work!`", parse_mode="markdown")
elif not HEROKU_APP_NAME:
await message.reply_text("`Please Add HEROKU_APP_NAME For This To Function To Work!`", parse_mode="markdown")
if HEROKU_APP_NAME and heroku_client:
try:
heroku_app = heroku_client.app(HEROKU_APP_NAME)
except:
await message.reply_text(message, "`Heroku Api Key And App Name Doesn't Match!`", parse_mode="markdown")
if heroku_app:
await func(client, message, heroku_app)

return heroku_cli

# Preparing For Update Bot
# Implement by https://github.com/jusidama18 and Based on this https://github.com/DevsExpo/FridayUserbot/blob/master/plugins/updater.py

def fetch_heroku_git_url(api_key, app_name):
if not api_key:
return None
if not app_name:
return None
heroku = heroku3.from_key(api_key)
try:
heroku_applications = heroku.apps()
except:
return None
heroku_app = None
for app in heroku_applications:
if app.name == app_name:
heroku_app = app
break
if not heroku_app:
return None
return heroku_app.git_url.replace("https://", "https://api:" + api_key + "@")

HEROKU_URL = fetch_heroku_git_url(HEROKU_API_KEY, HEROKU_APP_NAME)

def post_to_telegraph(a_title: str, content: str) -> str:
""" Create a Telegram Post using HTML Content """
Expand Down
4 changes: 4 additions & 0 deletions bot/helper/telegram_helper/bot_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,9 @@ def __init__(self):
self.TarWatchCommand = 'tarwatch'
self.DeleteCommand = 'del'
self.UsageCommand = 'usage'
self.MediaInfoCommand = 'mediainfo'
self.ConfigMenuCommand = 'config'
self.ShellCommand = 'shell'
self.UpdateCommand = 'update'

BotCommands = _BotCommands()
18 changes: 18 additions & 0 deletions bot/modules/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'''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"]
Loading

0 comments on commit 57d9e5a

Please sign in to comment.