v4.6.6 (#52)
- direct_links: Added racaty.net support - Update support group link - Added img in /stats command - Fix Index URL encode problem - Added support for password protected index links by magneto - stickers: Added /remove command to remove sticker an existing pack Co-authored-by: The Fierce Warrior <TheFierceWarrior@users.noreply.github.com> Co-authored-by: Dev Singh Rajput <magneto261290@users.noreply.github.com>
This commit is contained in:
parent
8f937c1b1f
commit
a077ecb66e
10
README.md
10
README.md
|
|
@ -27,8 +27,9 @@ This is a telegram bot writen in python for mirroring files on the internet to o
|
||||||
- Delete files from drive
|
- Delete files from drive
|
||||||
- Shortener support
|
- Shortener support
|
||||||
- Custom Filename (Only for url, telegram files and ytdl. Not for mega links and magnet/torrents)
|
- Custom Filename (Only for url, telegram files and ytdl. Not for mega links and magnet/torrents)
|
||||||
- Extracting password protected files and using custom filename see these examples:
|
- Extracting password protected files, using custom filename and download from password protected index links see these examples:
|
||||||
> https://telegra.ph/Magneto-Python-Aria---Custom-Filename-Examples-01-20
|
<p><a href="https://telegra.ph/Magneto-Python-Aria---Custom-Filename-Examples-01-20"> <img src="https://img.shields.io/badge/see%20on%20telegraph-grey?style=for-the-badge" width="190""/></a></p>
|
||||||
|
|
||||||
- Extract these filetypes and uploads to google drive
|
- Extract these filetypes and uploads to google drive
|
||||||
```
|
```
|
||||||
ZIP, RAR, TAR, 7z, ISO, WIM, CAB, GZIP, BZIP2,
|
ZIP, RAR, TAR, 7z, ISO, WIM, CAB, GZIP, BZIP2,
|
||||||
|
|
@ -141,7 +142,7 @@ sudo docker run mirrorbot
|
||||||
|
|
||||||
Fork this repo then upload **token.pickle** to your forks
|
Fork this repo then upload **token.pickle** to your forks
|
||||||
|
|
||||||
**NOTE**: If you didn't upload **token.pickle**, uploading will not working.
|
**NOTE**: If you didn't upload **token.pickle**, uploading will not work.
|
||||||
<p><a href="https://heroku.com/deploy"> <img src="https://img.shields.io/badge/Deploy%20To%20Heroku-blueviolet?style=for-the-badge&logo=heroku" width="200""/></a></p>
|
<p><a href="https://heroku.com/deploy"> <img src="https://img.shields.io/badge/Deploy%20To%20Heroku-blueviolet?style=for-the-badge&logo=heroku" width="200""/></a></p>
|
||||||
|
|
||||||
## Deploying on Heroku using heroku-cli
|
## Deploying on Heroku using heroku-cli
|
||||||
|
|
@ -246,6 +247,9 @@ machine host login username password my_youtube_password
|
||||||
```
|
```
|
||||||
where host is the name of extractor (eg. youtube, twitch). Multiple accounts of different hosts can be added each separated by a new line
|
where host is the name of extractor (eg. youtube, twitch). Multiple accounts of different hosts can be added each separated by a new line
|
||||||
|
|
||||||
|
# Support Group
|
||||||
|
<p><a href="https://t.me/SlamMirrorSupport"> <img src="https://img.shields.io/badge/Slam%20Mirror%20Support-black?style=for-the-badge&logo=telegram" width="230""/></a></p>
|
||||||
|
|
||||||
# Credits
|
# Credits
|
||||||
|
|
||||||
Thanks to:
|
Thanks to:
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ def stats(update, context):
|
||||||
f'<b>CPU:</b> {cpuUsage}%\n' \
|
f'<b>CPU:</b> {cpuUsage}%\n' \
|
||||||
f'<b>RAM:</b> {memory}%\n' \
|
f'<b>RAM:</b> {memory}%\n' \
|
||||||
f'<b>Disk:</b> {disk}%'
|
f'<b>Disk:</b> {disk}%'
|
||||||
sendMessage(stats, context.bot, update)
|
update.effective_message.reply_photo("https://telegra.ph/file/db03910496f06094f1f7a.jpg", stats, parse_mode=ParseMode.HTML)
|
||||||
|
|
||||||
|
|
||||||
@run_async
|
@run_async
|
||||||
|
|
@ -60,7 +60,7 @@ def chat_list(update, context):
|
||||||
def repo(update, context):
|
def repo(update, context):
|
||||||
bot.send_message(update.message.chat_id,
|
bot.send_message(update.message.chat_id,
|
||||||
reply_to_message_id=update.message.message_id,
|
reply_to_message_id=update.message.message_id,
|
||||||
text="Repo: https://github.com/breakdowns/slam-mirrorbot\nGroup: https://t.me/SlamMirrorSupportGroup", disable_web_page_preview=True)
|
text="Repo: https://github.com/breakdowns/slam-mirrorbot\nGroup: https://t.me/SlamMirrorSupport", disable_web_page_preview=True)
|
||||||
|
|
||||||
|
|
||||||
@run_async
|
@run_async
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,8 @@ def direct_link_generator(link: str):
|
||||||
return osdn(link)
|
return osdn(link)
|
||||||
elif 'github.com' in link:
|
elif 'github.com' in link:
|
||||||
return github(link)
|
return github(link)
|
||||||
|
elif 'racaty.net' in link:
|
||||||
|
return racaty(link)
|
||||||
else:
|
else:
|
||||||
raise DirectDownloadLinkException(f'No Direct link function found for {link}')
|
raise DirectDownloadLinkException(f'No Direct link function found for {link}')
|
||||||
|
|
||||||
|
|
@ -173,6 +175,22 @@ def github(url: str) -> str:
|
||||||
raise DirectDownloadLinkException("`Error: Can't extract the link`\n")
|
raise DirectDownloadLinkException("`Error: Can't extract the link`\n")
|
||||||
|
|
||||||
|
|
||||||
|
def racaty(url: str) -> str:
|
||||||
|
dl_url = ''
|
||||||
|
try:
|
||||||
|
link = re.findall(r'\bhttps?://.*racaty\.net\S+', url)[0]
|
||||||
|
except IndexError:
|
||||||
|
raise DirectDownloadLinkException("`No Racaty links found`\n")
|
||||||
|
reqs=requests.get(link)
|
||||||
|
bss=BeautifulSoup(reqs.text,'html.parser')
|
||||||
|
op=bss.find('input',{'name':'op'})['value']
|
||||||
|
id=bss.find('input',{'name':'id'})['value']
|
||||||
|
rep=requests.post(link,data={'op':op,'id':id})
|
||||||
|
bss2=BeautifulSoup(rep.text,'html.parser')
|
||||||
|
dl_url=bss2.find('a',{'id':'uniqueExpirylink'})['href']
|
||||||
|
return dl_url
|
||||||
|
|
||||||
|
|
||||||
def useragent():
|
def useragent():
|
||||||
"""
|
"""
|
||||||
useragent random setter
|
useragent random setter
|
||||||
|
|
|
||||||
|
|
@ -326,7 +326,8 @@ class GoogleDriveHelper:
|
||||||
else:
|
else:
|
||||||
buttons.buildbutton("☁️Drive Link☁️", durl)
|
buttons.buildbutton("☁️Drive Link☁️", durl)
|
||||||
if INDEX_URL is not None:
|
if INDEX_URL is not None:
|
||||||
url = requests.utils.requote_uri(f'{INDEX_URL}/{meta.get("name")}/')
|
url_path = requests.utils.quote(f'{meta.get("name")}')
|
||||||
|
url = f'{INDEX_URL}/{url_path}/'
|
||||||
if SHORTENER is not None and SHORTENER_API is not None:
|
if SHORTENER is not None and SHORTENER_API is not None:
|
||||||
siurl = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, url)).text
|
siurl = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, url)).text
|
||||||
buttons.buildbutton("⚡Index Link⚡", siurl)
|
buttons.buildbutton("⚡Index Link⚡", siurl)
|
||||||
|
|
@ -353,7 +354,8 @@ class GoogleDriveHelper:
|
||||||
except TypeError:
|
except TypeError:
|
||||||
pass
|
pass
|
||||||
if INDEX_URL is not None:
|
if INDEX_URL is not None:
|
||||||
url = requests.utils.requote_uri(f'{INDEX_URL}/{file.get("name")}')
|
url_path = requests.utils.quote(f'{file.get("name")}')
|
||||||
|
url = f'{INDEX_URL}/{url_path}'
|
||||||
if SHORTENER is not None and SHORTENER_API is not None:
|
if SHORTENER is not None and SHORTENER_API is not None:
|
||||||
siurl = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, url)).text
|
siurl = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, url)).text
|
||||||
buttons.buildbutton("⚡Index Link⚡", siurl)
|
buttons.buildbutton("⚡Index Link⚡", siurl)
|
||||||
|
|
@ -515,12 +517,14 @@ class GoogleDriveHelper:
|
||||||
else:
|
else:
|
||||||
msg += f"<b><a href={furl}>Drive Link</a></b>"
|
msg += f"<b><a href={furl}>Drive Link</a></b>"
|
||||||
if INDEX_URL is not None:
|
if INDEX_URL is not None:
|
||||||
url = requests.utils.requote_uri(f'{INDEX_URL}/{file.get("name")}/')
|
url_path = requests.utils.quote(f'{file.get("name")}')
|
||||||
|
url = f'{INDEX_URL}/{url_path}/'
|
||||||
if SHORTENER is not None and SHORTENER_API is not None:
|
if SHORTENER is not None and SHORTENER_API is not None:
|
||||||
siurl = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, url)).text
|
siurl = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, url)).text
|
||||||
msg += f' <b>| <a href="{siurl}">Index Link</a></b>'
|
msg += f' <b>| <a href="{siurl}">Index Link</a></b>'
|
||||||
else:
|
else:
|
||||||
msg += f' <b>| <a href="{url}">Index Link</a></b>'
|
msg += f' <b>| <a href="{url}">Index Link</a></b>'
|
||||||
|
|
||||||
else:
|
else:
|
||||||
furl = f"https://drive.google.com/uc?id={file.get('id')}&export=download"
|
furl = f"https://drive.google.com/uc?id={file.get('id')}&export=download"
|
||||||
msg += f"⁍<code>{file.get('name')}<br>({get_readable_file_size(int(file.get('size')))})📄</code><br>"
|
msg += f"⁍<code>{file.get('name')}<br>({get_readable_file_size(int(file.get('size')))})📄</code><br>"
|
||||||
|
|
@ -530,7 +534,8 @@ class GoogleDriveHelper:
|
||||||
else:
|
else:
|
||||||
msg += f"<b><a href={furl}>Drive Link</a></b>"
|
msg += f"<b><a href={furl}>Drive Link</a></b>"
|
||||||
if INDEX_URL is not None:
|
if INDEX_URL is not None:
|
||||||
url = requests.utils.requote_uri(f'{INDEX_URL}/{file.get("name")}')
|
url_path = requests.utils.quote(f'{file.get("name")}')
|
||||||
|
url = f'{INDEX_URL}/{url_path}'
|
||||||
if SHORTENER is not None and SHORTENER_API is not None:
|
if SHORTENER is not None and SHORTENER_API is not None:
|
||||||
siurl = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, url)).text
|
siurl = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, url)).text
|
||||||
msg += f' <b>| <a href="{siurl}">Index Link</a></b>'
|
msg += f' <b>| <a href="{siurl}">Index Link</a></b>'
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ from bot.helper.telegram_helper.bot_commands import BotCommands
|
||||||
from bot.helper.telegram_helper.filters import CustomFilters
|
from bot.helper.telegram_helper.filters import CustomFilters
|
||||||
from bot.helper.telegram_helper.message_utils import *
|
from bot.helper.telegram_helper.message_utils import *
|
||||||
from bot.helper.telegram_helper import button_build
|
from bot.helper.telegram_helper import button_build
|
||||||
|
import urllib
|
||||||
import pathlib
|
import pathlib
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
@ -154,7 +155,8 @@ class MirrorListener(listeners.MirrorListeners):
|
||||||
buttons.buildbutton("☁️Drive Link☁️", link)
|
buttons.buildbutton("☁️Drive Link☁️", link)
|
||||||
LOGGER.info(f'Done Uploading {download_dict[self.uid].name()}')
|
LOGGER.info(f'Done Uploading {download_dict[self.uid].name()}')
|
||||||
if INDEX_URL is not None:
|
if INDEX_URL is not None:
|
||||||
share_url = requests.utils.requote_uri(f'{INDEX_URL}/{download_dict[self.uid].name()}')
|
url_path = requests.utils.quote(f'{download_dict[self.uid].name()}')
|
||||||
|
share_url = f'{INDEX_URL}/{url_path}'
|
||||||
if os.path.isdir(f'{DOWNLOAD_DIR}/{self.uid}/{download_dict[self.uid].name()}'):
|
if os.path.isdir(f'{DOWNLOAD_DIR}/{self.uid}/{download_dict[self.uid].name()}'):
|
||||||
share_url += '/'
|
share_url += '/'
|
||||||
if SHORTENER is not None and SHORTENER_API is not None:
|
if SHORTENER is not None and SHORTENER_API is not None:
|
||||||
|
|
@ -202,10 +204,12 @@ class MirrorListener(listeners.MirrorListeners):
|
||||||
update_all_messages()
|
update_all_messages()
|
||||||
|
|
||||||
def _mirror(bot, update, isTar=False, extract=False):
|
def _mirror(bot, update, isTar=False, extract=False):
|
||||||
message_args = update.message.text.split(' ')
|
mesg = update.message.text.split('\n')
|
||||||
name_args = update.message.text.split('|')
|
message_args = mesg[0].split(' ')
|
||||||
|
name_args = mesg[0].split('|')
|
||||||
try:
|
try:
|
||||||
link = message_args[1]
|
link = message_args[1]
|
||||||
|
print(link)
|
||||||
if link.startswith("|") or link.startswith("pswd: "):
|
if link.startswith("|") or link.startswith("pswd: "):
|
||||||
link = ''
|
link = ''
|
||||||
except IndexError:
|
except IndexError:
|
||||||
|
|
@ -217,6 +221,15 @@ def _mirror(bot, update, isTar=False, extract=False):
|
||||||
name = ''
|
name = ''
|
||||||
except IndexError:
|
except IndexError:
|
||||||
name = ''
|
name = ''
|
||||||
|
try:
|
||||||
|
ussr = urllib.parse.quote(mesg[1], safe='')
|
||||||
|
pssw = urllib.parse.quote(mesg[2], safe='')
|
||||||
|
except:
|
||||||
|
ussr = ''
|
||||||
|
pssw = ''
|
||||||
|
if ussr != '' and pssw != '':
|
||||||
|
link = link.split("://", maxsplit=1)
|
||||||
|
link = f'{link[0]}://{ussr}:{pssw}@{link[1]}'
|
||||||
pswd = re.search('(?<=pswd: )(.*)', update.message.text)
|
pswd = re.search('(?<=pswd: )(.*)', update.message.text)
|
||||||
if pswd is not None:
|
if pswd is not None:
|
||||||
pswd = pswd.groups()
|
pswd = pswd.groups()
|
||||||
|
|
|
||||||
|
|
@ -355,6 +355,21 @@ def kang(update: Update, context: CallbackContext):
|
||||||
os.remove("kangsticker.tgs")
|
os.remove("kangsticker.tgs")
|
||||||
|
|
||||||
|
|
||||||
|
@run_async
|
||||||
|
def delsticker(update, context):
|
||||||
|
msg = update.effective_message
|
||||||
|
if msg.reply_to_message and msg.reply_to_message.sticker:
|
||||||
|
file_id = msg.reply_to_message.sticker.file_id
|
||||||
|
context.bot.delete_sticker_from_set(file_id)
|
||||||
|
msg.reply_text(
|
||||||
|
"Deleted!"
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
update.effective_message.reply_text(
|
||||||
|
"Please reply to sticker message to del sticker"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def makepack_internal(
|
def makepack_internal(
|
||||||
update,
|
update,
|
||||||
context,
|
context,
|
||||||
|
|
@ -426,16 +441,18 @@ def makepack_internal(
|
||||||
@run_async
|
@run_async
|
||||||
def stickhelp(update, context):
|
def stickhelp(update, context):
|
||||||
help_string = '''
|
help_string = '''
|
||||||
• `/stickerid`*:* reply to a sticker to me to tell you its file ID.
|
• `/stickerid`*:* Reply to a sticker to me to tell you its file ID.
|
||||||
• `/getsticker`*:* reply to a sticker to me to upload its raw PNG file.
|
• `/getsticker`*:* Reply to a sticker to me to upload its raw PNG file.
|
||||||
• `/kang`*:* reply to a sticker to add it to your pack.
|
• `/kang`*:* Reply to a sticker to add it to your pack.
|
||||||
• `/stickers`*:* Find stickers for given term on combot sticker catalogue
|
• `/remove`*:* Replay to a sticker to remove sticker from an existing pack.
|
||||||
|
• `/stickers`*:* Find stickers for given term on combot sticker catalogue.
|
||||||
'''
|
'''
|
||||||
update.effective_message.reply_photo("https://telegra.ph/file/db03910496f06094f1f7a.jpg", help_string, parse_mode=ParseMode.MARKDOWN)
|
update.effective_message.reply_photo("https://telegra.ph/file/db03910496f06094f1f7a.jpg", help_string, parse_mode=ParseMode.MARKDOWN)
|
||||||
|
|
||||||
STICKERID_HANDLER = CommandHandler("stickerid", stickerid)
|
STICKERID_HANDLER = CommandHandler("stickerid", stickerid)
|
||||||
GETSTICKER_HANDLER = CommandHandler("getsticker", getsticker)
|
GETSTICKER_HANDLER = CommandHandler("getsticker", getsticker)
|
||||||
KANG_HANDLER = CommandHandler("kang", kang)
|
KANG_HANDLER = CommandHandler("kang", kang)
|
||||||
|
DEL_HANDLER = CommandHandler("remove", delsticker)
|
||||||
STICKERS_HANDLER = CommandHandler("stickers", cb_sticker)
|
STICKERS_HANDLER = CommandHandler("stickers", cb_sticker)
|
||||||
STICKHELP_HANDLER = CommandHandler("stickerhelp", stickhelp)
|
STICKHELP_HANDLER = CommandHandler("stickerhelp", stickhelp)
|
||||||
|
|
||||||
|
|
@ -444,4 +461,5 @@ dispatcher.add_handler(STICKERS_HANDLER)
|
||||||
dispatcher.add_handler(STICKERID_HANDLER)
|
dispatcher.add_handler(STICKERID_HANDLER)
|
||||||
dispatcher.add_handler(GETSTICKER_HANDLER)
|
dispatcher.add_handler(GETSTICKER_HANDLER)
|
||||||
dispatcher.add_handler(KANG_HANDLER)
|
dispatcher.add_handler(KANG_HANDLER)
|
||||||
|
dispatcher.add_handler(DEL_HANDLER)
|
||||||
dispatcher.add_handler(STICKHELP_HANDLER)
|
dispatcher.add_handler(STICKHELP_HANDLER)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue