Skip to content
This repository was archived by the owner on Dec 4, 2023. It is now read-only.

Commit 57d9e5a

Browse files
Hafitz Setyaanasty17jusidama18a092devsxd003
authored
v4.8.7 (#221)
- 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]>
1 parent d2173c9 commit 57d9e5a

15 files changed

+434
-10
lines changed

README.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,25 @@
1818
# Features supported:
1919
## Additional Features
2020
- Get detailed info about replied media (Only for Telegram file)
21-
- Nyaa.si and Sukebei Torrent search
2221
- Speedtest with picture results
2322
- Stop duplicate cloning Google Drive & mirroring Mega support
2423
- Limiting size Torrent/Direct, Mega, cloning Google Drive support
2524
- Sudo with Database support
2625
- Multiple Trackers support
2726
- Check Heroku dynos stats
27+
- Heroku config support
28+
- Updater (Only for Heroku)
2829
- Extracting **tar.xz** support
30+
- Create Tar Google Drive folder
2931
- Custom image support
3032
- Counting file/folder
3133
- Shell and Executor
3234
- View Link button
35+
- Torrent search supported:
36+
```
37+
nyaa, sukebei, 1337x, piratebay, tgx,
38+
yts, eztv, torlock, rarbg
39+
```
3340
- Direct links supported:
3441
```
3542
letsupload.io, hxfile.co, anonfiles.com, fembed.com, femax20.com, layarkacaxxi.icu,
@@ -129,6 +136,8 @@ Fill up rest of the fields. Meaning of each fields are discussed below:
129136
- **DOWNLOAD_DIR**: The path to the local folder where the downloads should be downloaded to
130137
- **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)
131138
- **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)
139+
- **UPSTREAM_REPO**: Link for Bot Upstream Repo, if you want default update, fill ```https://github.com/breakdowns/slam-mirrorbot```.
140+
- **UPSTREAM_BRANCH**: Link for Bot Upstream Repo (Recommended using master branch)
132141
### Optional Field
133142
- **AUTHORIZED_CHATS**: Fill user_id and chat_id of you want to authorize.
134143
- **IS_TEAM_DRIVE**: Set to `True` if `GDRIVE_FOLDER_ID` is from a Team Drive else `False` or Leave it empty.

app.json

+10
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,16 @@
7474
"description": "Add the Heroku app name here.",
7575
"required": true
7676
},
77+
"UPSTREAM_REPO": {
78+
"description": "Link for Bot Upstream Repo, If you want default update, Fill https://github.com/breakdowns/slam-mirrorbot.",
79+
"value": "https://github.com/breakdowns/slam-mirrorbot",
80+
"required": true
81+
},
82+
"UPSTREAM_BRANCH": {
83+
"description": "Branch name for Upstream Repo (Recommended using master branch).",
84+
"value": "master",
85+
"required": true
86+
},
7787
"UPTOBOX_TOKEN": {
7888
"description": "Uptobox premium token to mirror uptobox links. Get it from https://uptobox.com/my_account.",
7989
"required": false

bot/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ def mktable():
100100
AUTO_DELETE_MESSAGE_DURATION = int(getConfig('AUTO_DELETE_MESSAGE_DURATION'))
101101
TELEGRAM_API = getConfig('TELEGRAM_API')
102102
TELEGRAM_HASH = getConfig('TELEGRAM_HASH')
103+
UPSTREAM_REPO = getConfig('UPSTREAM_REPO')
104+
UPSTREAM_BRANCH = getConfig('UPSTREAM_BRANCH')
103105
except KeyError as e:
104106
LOGGER.error("One or more env variables missing! Exiting now")
105107
exit(1)

bot/__main__.py

+14-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import shutil, psutil
22
import signal
33
import os
4+
import importlib
45

56
from pyrogram import idle
67
from bot import app
@@ -18,7 +19,11 @@
1819
from .helper.ext_utils.bot_utils import get_readable_file_size, get_readable_time
1920
from .helper.telegram_helper.filters import CustomFilters
2021
from bot.helper.telegram_helper import button_build
21-
from .modules import authorize, list, cancel_mirror, mirror_status, mirror, clone, watch, shell, eval, search, delete, speedtest, usage, mediainfo, count
22+
from bot.modules import ALL_MODULES # Auto Load all modules without name problems
23+
24+
for module in ALL_MODULES:
25+
imported_module = importlib.import_module("bot.modules." + module)
26+
importlib.reload(imported_module)
2227

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

@@ -129,13 +134,17 @@ def bot_help(update, context):
129134
130135
/{BotCommands.LogCommand}: Get a log file of the bot. Handy for getting crash reports
131136
137+
/{BotCommands.ConfigMenuCommand}: Get Info Menu about bot config (Owner Only).
138+
139+
/{BotCommands.UpdateCommand}: Update Bot from Upstream Repo. (Owner Only).
140+
132141
/{BotCommands.UsageCommand}: To see Heroku Dyno Stats (Owner & Sudo only).
133142
134143
/{BotCommands.SpeedCommand}: Check Internet Speed of the Host
135144
136-
/shell: Run commands in Shell (Terminal).
145+
/{BotCommands.MediaInfoCommand}: Get detailed info about replied media (Only for Telegram file).
137146
138-
/mediainfo: Get detailed info about replied media (Only for Telegram file).
147+
/{BotCommands.ShellCommand}: Run commands in Shell (Terminal).
139148
140149
/tshelp: Get help for Torrent search module.
141150
'''
@@ -167,7 +176,7 @@ def bot_help(update, context):
167176
168177
/{BotCommands.SpeedCommand}: Check Internet Speed of the Host
169178
170-
/mediainfo: Get detailed info about replied media (Only for Telegram file).
179+
/{BotCommands.MediaInfoCommand}: Get detailed info about replied media (Only for Telegram file).
171180
172181
/tshelp: Get help for Torrent search module.
173182
'''
@@ -193,6 +202,7 @@ def bot_help(update, context):
193202
BotCommand(f'{BotCommands.StatusCommand}','Get Mirror Status message'),
194203
BotCommand(f'{BotCommands.StatsCommand}','Bot Usage Stats'),
195204
BotCommand(f'{BotCommands.HelpCommand}','Get Detailed Help'),
205+
BotCommand(f'{BotCommands.MediaInfoCommand}','Get detailed info about replied media'),
196206
BotCommand(f'{BotCommands.SpeedCommand}','Check Speed of the host'),
197207
BotCommand(f'{BotCommands.LogCommand}','Bot Log [owner/sudo only]'),
198208
BotCommand(f'{BotCommands.RestartCommand}','Restart bot [owner/sudo only]')]

bot/helper/__init__.py

+70
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,78 @@
11
import asyncio
22
import os
33
import shlex
4+
import heroku3
5+
6+
from functools import wraps
7+
from pyrogram.types import Message
48
from typing import Tuple
59
from html_telegraph_poster import TelegraphPoster
10+
from bot import HEROKU_API_KEY, HEROKU_APP_NAME
11+
12+
# Implement by https://github.com/jusidama18
13+
# Setting Message
14+
15+
def get_text(message: Message) -> [None, str]:
16+
"""Extract Text From Commands"""
17+
text_to_return = message.text
18+
if message.text is None:
19+
return None
20+
if " " in text_to_return:
21+
try:
22+
return message.text.split(None, 1)[1]
23+
except IndexError:
24+
return None
25+
else:
26+
return None
27+
28+
# Preparing For Setting Config
29+
# Implement by https://github.com/jusidama18 and Based on this https://github.com/DevsExpo/FridayUserbot/blob/master/plugins/heroku_helpers.py
30+
31+
heroku_client = None
32+
if HEROKU_API_KEY:
33+
heroku_client = heroku3.from_key(HEROKU_API_KEY)
34+
35+
def check_heroku(func):
36+
@wraps(func)
37+
async def heroku_cli(client, message):
38+
heroku_app = None
39+
if not heroku_client:
40+
await message.reply_text("`Please Add HEROKU_API_KEY Key For This To Function To Work!`", parse_mode="markdown")
41+
elif not HEROKU_APP_NAME:
42+
await message.reply_text("`Please Add HEROKU_APP_NAME For This To Function To Work!`", parse_mode="markdown")
43+
if HEROKU_APP_NAME and heroku_client:
44+
try:
45+
heroku_app = heroku_client.app(HEROKU_APP_NAME)
46+
except:
47+
await message.reply_text(message, "`Heroku Api Key And App Name Doesn't Match!`", parse_mode="markdown")
48+
if heroku_app:
49+
await func(client, message, heroku_app)
50+
51+
return heroku_cli
52+
53+
# Preparing For Update Bot
54+
# Implement by https://github.com/jusidama18 and Based on this https://github.com/DevsExpo/FridayUserbot/blob/master/plugins/updater.py
55+
56+
def fetch_heroku_git_url(api_key, app_name):
57+
if not api_key:
58+
return None
59+
if not app_name:
60+
return None
61+
heroku = heroku3.from_key(api_key)
62+
try:
63+
heroku_applications = heroku.apps()
64+
except:
65+
return None
66+
heroku_app = None
67+
for app in heroku_applications:
68+
if app.name == app_name:
69+
heroku_app = app
70+
break
71+
if not heroku_app:
72+
return None
73+
return heroku_app.git_url.replace("https://", "https://api:" + api_key + "@")
74+
75+
HEROKU_URL = fetch_heroku_git_url(HEROKU_API_KEY, HEROKU_APP_NAME)
676

777
def post_to_telegraph(a_title: str, content: str) -> str:
878
""" Create a Telegram Post using HTML Content """

bot/helper/telegram_helper/bot_commands.py

+4
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,9 @@ def __init__(self):
2525
self.TarWatchCommand = 'tarwatch'
2626
self.DeleteCommand = 'del'
2727
self.UsageCommand = 'usage'
28+
self.MediaInfoCommand = 'mediainfo'
29+
self.ConfigMenuCommand = 'config'
30+
self.ShellCommand = 'shell'
31+
self.UpdateCommand = 'update'
2832

2933
BotCommands = _BotCommands()

bot/modules/__init__.py

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
'''Methods Directory.'''
2+
# Module folder for modules using Telegram.
3+
# For easier development.
4+
5+
def __list_all_modules():
6+
from os.path import dirname, basename, isfile
7+
import glob
8+
# This generates a list of modules in this folder for the * in __main__ to work.
9+
mod_paths = glob.glob(dirname(__file__) + "/*.py")
10+
return [
11+
basename(f)[:-3] for f in mod_paths if isfile(f)
12+
and f.endswith(".py")
13+
and not f.endswith('__init__.py')
14+
]
15+
16+
17+
ALL_MODULES = sorted(__list_all_modules())
18+
__all__ = ALL_MODULES + ["ALL_MODULES"]

0 commit comments

Comments
 (0)