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

Commit

Permalink
v4.6.6 (#52)
Browse files Browse the repository at this point in the history
- 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 <[email protected]>
Co-authored-by: Dev Singh Rajput <[email protected]>
  • Loading branch information
3 people authored Apr 18, 2021
1 parent 8f937c1 commit a077ecb
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 16 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ This is a telegram bot writen in python for mirroring files on the internet to o
- Delete files from drive
- Shortener support
- 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:
> https://telegra.ph/Magneto-Python-Aria---Custom-Filename-Examples-01-20
- Extracting password protected files, using custom filename and download from password protected index links see these examples:
<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
```
ZIP, RAR, TAR, 7z, ISO, WIM, CAB, GZIP, BZIP2,
Expand Down Expand Up @@ -141,7 +142,7 @@ sudo docker run mirrorbot

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>

## Deploying on Heroku using heroku-cli
Expand Down Expand Up @@ -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

# 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

Thanks to:
Expand Down
4 changes: 2 additions & 2 deletions bot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def stats(update, context):
f'<b>CPU:</b> {cpuUsage}%\n' \
f'<b>RAM:</b> {memory}%\n' \
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
Expand All @@ -60,7 +60,7 @@ def chat_list(update, context):
def repo(update, context):
bot.send_message(update.message.chat_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
Expand Down
18 changes: 18 additions & 0 deletions bot/helper/mirror_utils/download_utils/direct_link_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ def direct_link_generator(link: str):
return osdn(link)
elif 'github.com' in link:
return github(link)
elif 'racaty.net' in link:
return racaty(link)
else:
raise DirectDownloadLinkException(f'No Direct link function found for {link}')

Expand Down Expand Up @@ -173,6 +175,22 @@ def github(url: str) -> str:
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():
"""
useragent random setter
Expand Down
13 changes: 9 additions & 4 deletions bot/helper/mirror_utils/upload_utils/gdriveTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,8 @@ def clone(self, link):
else:
buttons.buildbutton("☁️Drive Link☁️", durl)
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:
siurl = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, url)).text
buttons.buildbutton("⚡Index Link⚡", siurl)
Expand All @@ -353,7 +354,8 @@ def clone(self, link):
except TypeError:
pass
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:
siurl = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, url)).text
buttons.buildbutton("⚡Index Link⚡", siurl)
Expand Down Expand Up @@ -515,12 +517,14 @@ def drive_list(self, fileName):
else:
msg += f"<b><a href={furl}>Drive Link</a></b>"
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:
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>'
else:
msg += f' <b>| <a href="{url}">Index Link</a></b>'

else:
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>"
Expand All @@ -530,7 +534,8 @@ def drive_list(self, fileName):
else:
msg += f"<b><a href={furl}>Drive Link</a></b>"
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:
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>'
Expand Down
19 changes: 16 additions & 3 deletions bot/modules/mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from bot.helper.telegram_helper.filters import CustomFilters
from bot.helper.telegram_helper.message_utils import *
from bot.helper.telegram_helper import button_build
import urllib
import pathlib
import os
import subprocess
Expand Down Expand Up @@ -154,7 +155,8 @@ def onUploadComplete(self, link: str, size):
buttons.buildbutton("☁️Drive Link☁️", link)
LOGGER.info(f'Done Uploading {download_dict[self.uid].name()}')
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()}'):
share_url += '/'
if SHORTENER is not None and SHORTENER_API is not None:
Expand Down Expand Up @@ -202,10 +204,12 @@ def onUploadError(self, error):
update_all_messages()

def _mirror(bot, update, isTar=False, extract=False):
message_args = update.message.text.split(' ')
name_args = update.message.text.split('|')
mesg = update.message.text.split('\n')
message_args = mesg[0].split(' ')
name_args = mesg[0].split('|')
try:
link = message_args[1]
print(link)
if link.startswith("|") or link.startswith("pswd: "):
link = ''
except IndexError:
Expand All @@ -217,6 +221,15 @@ def _mirror(bot, update, isTar=False, extract=False):
name = ''
except IndexError:
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)
if pswd is not None:
pswd = pswd.groups()
Expand Down
26 changes: 22 additions & 4 deletions bot/modules/stickers.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,21 @@ def kang(update: Update, context: CallbackContext):
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(
update,
context,
Expand Down Expand Up @@ -426,16 +441,18 @@ def makepack_internal(
@run_async
def stickhelp(update, context):
help_string = '''
• `/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.
• `/kang`*:* reply to a sticker to add it to your pack.
• `/stickers`*:* Find stickers for given term on combot sticker catalogue
• `/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.
• `/kang`*:* Reply to a sticker to add it to your pack.
• `/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)

STICKERID_HANDLER = CommandHandler("stickerid", stickerid)
GETSTICKER_HANDLER = CommandHandler("getsticker", getsticker)
KANG_HANDLER = CommandHandler("kang", kang)
DEL_HANDLER = CommandHandler("remove", delsticker)
STICKERS_HANDLER = CommandHandler("stickers", cb_sticker)
STICKHELP_HANDLER = CommandHandler("stickerhelp", stickhelp)

Expand All @@ -444,4 +461,5 @@ def stickhelp(update, context):
dispatcher.add_handler(STICKERID_HANDLER)
dispatcher.add_handler(GETSTICKER_HANDLER)
dispatcher.add_handler(KANG_HANDLER)
dispatcher.add_handler(DEL_HANDLER)
dispatcher.add_handler(STICKHELP_HANDLER)

0 comments on commit a077ecb

Please sign in to comment.