v4.6.5 (#50)
- Remove USE_TELEGRAPH, cuz its causes some issue - Added support group link in /repo command
This commit is contained in:
parent
d9c3249e75
commit
4fa3f74a36
16
README.md
16
README.md
|
|
@ -83,7 +83,6 @@ Fill up rest of the fields. Meaning of each fields are discussed below:
|
||||||
- **INDEX_URL**: (Optional field) Refer to https://github.com/maple3142/GDIndex/ The URL should not have any trailing '/'
|
- **INDEX_URL**: (Optional field) Refer to https://github.com/maple3142/GDIndex/ The URL should not have any trailing '/'
|
||||||
- **API_KEY**: This is to authenticate to your telegram account for downloading Telegram files. You can get this from https://my.telegram.org DO NOT put this in quotes.
|
- **API_KEY**: This is to authenticate to your telegram account for downloading Telegram files. You can get this from https://my.telegram.org DO NOT put this in quotes.
|
||||||
- **API_HASH**: This is to authenticate to your telegram account for downloading Telegram files. You can get this from https://my.telegram.org
|
- **API_HASH**: This is to authenticate to your telegram account for downloading Telegram files. You can get this from https://my.telegram.org
|
||||||
- **USE_TELEGRAPH**: Set to `true` to use Telegra.ph for search results from /list bot command, or else set to `false`.
|
|
||||||
- **MEGA_API_KEY**: Mega.nz api key to mirror mega.nz links. Get it from [Mega SDK Page](https://mega.nz/sdk)
|
- **MEGA_API_KEY**: Mega.nz api key to mirror mega.nz links. Get it from [Mega SDK Page](https://mega.nz/sdk)
|
||||||
- **MEGA_EMAIL_ID**: Your email id you used to sign up on mega.nz for using premium accounts (Leave th)
|
- **MEGA_EMAIL_ID**: Your email id you used to sign up on mega.nz for using premium accounts (Leave th)
|
||||||
- **MEGA_PASSWORD**: Your password for your mega.nz account
|
- **MEGA_PASSWORD**: Your password for your mega.nz account
|
||||||
|
|
@ -140,8 +139,9 @@ sudo docker run mirrorbot
|
||||||
|
|
||||||
## Deploying on Heroku
|
## Deploying on Heroku
|
||||||
|
|
||||||
- Fork this repo
|
Fork this repo then upload **token.pickle** to your forks
|
||||||
- Upload **token.pickle** to your forks
|
|
||||||
|
**NOTE**: If you didn't upload **token.pickle**, uploading will not working.
|
||||||
<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
|
||||||
|
|
@ -155,15 +155,15 @@ heroku login
|
||||||
```
|
```
|
||||||
- Create a new heroku app:
|
- Create a new heroku app:
|
||||||
```
|
```
|
||||||
heroku create <appname>
|
heroku create appname
|
||||||
```
|
```
|
||||||
- Select This App in your Heroku-cli:
|
- Select This App in your Heroku-cli:
|
||||||
```
|
```
|
||||||
heroku git:remote -a <appname>
|
heroku git:remote -a appname
|
||||||
```
|
```
|
||||||
- Change Dyno Stack to a Docker Container:
|
- Change Dyno Stack to a Docker Container:
|
||||||
```
|
```
|
||||||
heroku stack:set container -a <appname>
|
heroku stack:set container -a appname
|
||||||
```
|
```
|
||||||
- Add Private Credentials and Config Stuff:
|
- Add Private Credentials and Config Stuff:
|
||||||
```
|
```
|
||||||
|
|
@ -180,11 +180,11 @@ git push heroku master --force
|
||||||
- Restart Worker by these commands,You can Do it manually too in heroku.
|
- Restart Worker by these commands,You can Do it manually too in heroku.
|
||||||
- For Turning off the Bot:
|
- For Turning off the Bot:
|
||||||
```
|
```
|
||||||
heroku ps:scale worker=0 -a <appname>
|
heroku ps:scale worker=0 -a appname
|
||||||
```
|
```
|
||||||
- For Turning on the Bot:
|
- For Turning on the Bot:
|
||||||
```
|
```
|
||||||
heroku ps:scale worker=1 -a <appname>
|
heroku ps:scale worker=1 -a appname
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
|
||||||
5
app.json
5
app.json
|
|
@ -66,11 +66,6 @@
|
||||||
"description": "This is to authenticate to your telegram account for downloading Telegram files. You can get this from https://my.telegram.org.",
|
"description": "This is to authenticate to your telegram account for downloading Telegram files. You can get this from https://my.telegram.org.",
|
||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
"USE_TELEGRAPH": {
|
|
||||||
"description": "Set to true to use Telegra.ph for search results from /list bot command, or else set to false.",
|
|
||||||
"value": "",
|
|
||||||
"required": true
|
|
||||||
},
|
|
||||||
"HEROKU_API_KEY": {
|
"HEROKU_API_KEY": {
|
||||||
"description": "Your Heroku API key, get it from https://dashboard.heroku.com/account.",
|
"description": "Your Heroku API key, get it from https://dashboard.heroku.com/account.",
|
||||||
"required": true
|
"required": true
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,28 @@ except KeyError as e:
|
||||||
LOGGER.error("One or more env variables missing! Exiting now")
|
LOGGER.error("One or more env variables missing! Exiting now")
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
|
LOGGER.info("Generating USER_SESSION_STRING")
|
||||||
|
with Client(':memory:', api_id=int(TELEGRAM_API), api_hash=TELEGRAM_HASH, bot_token=BOT_TOKEN) as app:
|
||||||
|
USER_SESSION_STRING = app.export_session_string()
|
||||||
|
|
||||||
|
#Generate Telegraph Token
|
||||||
|
sname = ''.join(random.SystemRandom().choices(string.ascii_letters, k=8))
|
||||||
|
LOGGER.info("Generating Telegraph Token using '" + sname + "' name")
|
||||||
|
telegraph = Telegraph()
|
||||||
|
telegraph.create_account(short_name=sname)
|
||||||
|
telegraph_token = telegraph.get_access_token()
|
||||||
|
LOGGER.info("Telegraph Token Generated: '" + telegraph_token + "'")
|
||||||
|
|
||||||
|
try:
|
||||||
|
HEROKU_API_KEY = getConfig('HEROKU_API_KEY')
|
||||||
|
except KeyError:
|
||||||
|
logging.warning('HEROKU API KEY not provided!')
|
||||||
|
HEROKU_API_KEY = None
|
||||||
|
try:
|
||||||
|
HEROKU_APP_NAME = getConfig('HEROKU_APP_NAME')
|
||||||
|
except KeyError:
|
||||||
|
logging.warning('HEROKU APP NAME not provided!')
|
||||||
|
HEROKU_APP_NAME = None
|
||||||
try:
|
try:
|
||||||
MAX_TORRENT_SIZE = int(getConfig("MAX_TORRENT_SIZE"))
|
MAX_TORRENT_SIZE = int(getConfig("MAX_TORRENT_SIZE"))
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
|
@ -102,44 +124,6 @@ try:
|
||||||
ENABLE_FILESIZE_LIMIT = False
|
ENABLE_FILESIZE_LIMIT = False
|
||||||
except KeyError:
|
except KeyError:
|
||||||
ENABLE_FILESIZE_LIMIT = False
|
ENABLE_FILESIZE_LIMIT = False
|
||||||
|
|
||||||
try:
|
|
||||||
if os.environ['USE_TELEGRAPH'].upper() == 'TRUE':
|
|
||||||
USE_TELEGRAPH = True
|
|
||||||
else:
|
|
||||||
raise KeyError
|
|
||||||
except KeyError:
|
|
||||||
USE_TELEGRAPH = False
|
|
||||||
|
|
||||||
# Generate USER_SESSION_STRING
|
|
||||||
LOGGER.info("Generating USER_SESSION_STRING")
|
|
||||||
with Client(':memory:', api_id=int(TELEGRAM_API), api_hash=TELEGRAM_HASH, bot_token=BOT_TOKEN) as app:
|
|
||||||
USER_SESSION_STRING = app.export_session_string()
|
|
||||||
|
|
||||||
# Generate TELEGRAPH_TOKEN
|
|
||||||
if USE_TELEGRAPH:
|
|
||||||
sname = ''.join(random.SystemRandom().choices(string.ascii_letters, k=8))
|
|
||||||
LOGGER.info("Using Telegra.ph")
|
|
||||||
LOGGER.info("Generating TELEGRAPH_TOKEN using '" + sname + "' name")
|
|
||||||
telegraph = Telegraph()
|
|
||||||
telegraph.create_account(short_name=sname)
|
|
||||||
TELEGRAPH_TOKEN = telegraph.get_access_token()
|
|
||||||
LOGGER.info("Telegraph Token Generated: '" + TELEGRAPH_TOKEN + "'")
|
|
||||||
if not USE_TELEGRAPH:
|
|
||||||
TELEGRAPH_TOKEN = None
|
|
||||||
LOGGER.info("Not Using Telegra.ph")
|
|
||||||
pass
|
|
||||||
|
|
||||||
try:
|
|
||||||
HEROKU_API_KEY = getConfig('HEROKU_API_KEY')
|
|
||||||
except KeyError:
|
|
||||||
logging.warning('HEROKU API KEY not provided!')
|
|
||||||
HEROKU_API_KEY = None
|
|
||||||
try:
|
|
||||||
HEROKU_APP_NAME = getConfig('HEROKU_APP_NAME')
|
|
||||||
except KeyError:
|
|
||||||
logging.warning('HEROKU APP NAME not provided!')
|
|
||||||
HEROKU_APP_NAME = None
|
|
||||||
try:
|
try:
|
||||||
UPTOBOX_TOKEN = getConfig('UPTOBOX_TOKEN')
|
UPTOBOX_TOKEN = getConfig('UPTOBOX_TOKEN')
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
|
|
||||||
|
|
@ -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", disable_web_page_preview=True)
|
text="Repo: https://github.com/breakdowns/slam-mirrorbot\nGroup: https://t.me/SlamMirrorSupportGroup", disable_web_page_preview=True)
|
||||||
|
|
||||||
|
|
||||||
@run_async
|
@run_async
|
||||||
|
|
|
||||||
|
|
@ -29,18 +29,19 @@ class AriaDownloadHelper(DownloadHelper):
|
||||||
aria2.remove([download])
|
aria2.remove([download])
|
||||||
return
|
return
|
||||||
update_all_messages()
|
update_all_messages()
|
||||||
gdrive = GoogleDriveHelper(None)
|
|
||||||
smsg, button = gdrive.drive_list(sname)
|
|
||||||
if STOP_DUPLICATE_MIRROR:
|
if STOP_DUPLICATE_MIRROR:
|
||||||
if smsg:
|
if dl.getListener().isTar == True:
|
||||||
dl.getListener().onDownloadError(f'😡 File is already available in drive. You should have search before mirror any file. You might get ban if you do this again. This download has been stopped.\n\n')
|
sname = sname + ".tar"
|
||||||
print(dl.getListener())
|
if dl.getListener().extract == True:
|
||||||
if button:
|
smsg = None
|
||||||
sendMarkup("Here are the search results:👇\n", dl.getListener().bot, dl.getListener().update, button)
|
else:
|
||||||
else:
|
gdrive = GoogleDriveHelper(None)
|
||||||
sendMessage("Here are the search results:👇\n" + smsg, dl.getListener().bot, dl.getListener().update)
|
smsg, button = gdrive.drive_list(sname)
|
||||||
aria2.remove([download])
|
if smsg:
|
||||||
return
|
dl.getListener().onDownloadError(f'😡 File is already available in drive. You should have search before mirror any file. You might get ban if you do this again. This download has been stopped.\n\n')
|
||||||
|
sendMarkup(" Here are the search results:👇", dl.getListener().bot, dl.getListener().update, button)
|
||||||
|
aria2.remove([download])
|
||||||
|
return
|
||||||
update_all_messages()
|
update_all_messages()
|
||||||
|
|
||||||
def __onDownloadComplete(self, api: API, gid):
|
def __onDownloadComplete(self, api: API, gid):
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,8 @@ from tenacity import *
|
||||||
from telegram import InlineKeyboardMarkup
|
from telegram import InlineKeyboardMarkup
|
||||||
from bot.helper.telegram_helper import button_build
|
from bot.helper.telegram_helper import button_build
|
||||||
from telegraph import Telegraph
|
from telegraph import Telegraph
|
||||||
from bot import parent_id, DOWNLOAD_DIR, IS_TEAM_DRIVE, INDEX_URL, USE_TELEGRAPH, \
|
from bot import parent_id, DOWNLOAD_DIR, IS_TEAM_DRIVE, INDEX_URL, \
|
||||||
USE_SERVICE_ACCOUNTS, download_dict, TELEGRAPH_TOKEN, BUTTON_THREE_NAME, BUTTON_THREE_URL, BUTTON_FOUR_NAME, BUTTON_FOUR_URL, BUTTON_FIVE_NAME, BUTTON_FIVE_URL, SHORTENER, SHORTENER_API
|
USE_SERVICE_ACCOUNTS, download_dict, telegraph_token, BUTTON_THREE_NAME, BUTTON_THREE_URL, BUTTON_FOUR_NAME, BUTTON_FOUR_URL, BUTTON_FIVE_NAME, BUTTON_FIVE_URL, SHORTENER, SHORTENER_API
|
||||||
from bot.helper.ext_utils.bot_utils import *
|
from bot.helper.ext_utils.bot_utils import *
|
||||||
from bot.helper.ext_utils.fs_utils import get_mime_type, get_path_size
|
from bot.helper.ext_utils.fs_utils import get_mime_type, get_path_size
|
||||||
|
|
||||||
|
|
@ -477,7 +477,7 @@ class GoogleDriveHelper:
|
||||||
if nxt_page < self.num_of_path:
|
if nxt_page < self.num_of_path:
|
||||||
content += f'<b> | <a href="https://telegra.ph/{self.path[nxt_page]}">Next</a></b>'
|
content += f'<b> | <a href="https://telegra.ph/{self.path[nxt_page]}">Next</a></b>'
|
||||||
nxt_page += 1
|
nxt_page += 1
|
||||||
Telegraph(access_token=TELEGRAPH_TOKEN).edit_page(path = self.path[prev_page],
|
Telegraph(access_token=telegraph_token).edit_page(path = self.path[prev_page],
|
||||||
title = 'Slam Mirror Bot - Search',
|
title = 'Slam Mirror Bot - Search',
|
||||||
author_name='Slam Mirror Bot',
|
author_name='Slam Mirror Bot',
|
||||||
author_url='https://github.com/breakdowns/slam-mirrorbot',
|
author_url='https://github.com/breakdowns/slam-mirrorbot',
|
||||||
|
|
@ -503,87 +503,69 @@ class GoogleDriveHelper:
|
||||||
fields='files(id, name, mimeType, size)',
|
fields='files(id, name, mimeType, size)',
|
||||||
orderBy='name asc').execute()
|
orderBy='name asc').execute()
|
||||||
content_count = 0
|
content_count = 0
|
||||||
if USE_TELEGRAPH:
|
if response["files"]:
|
||||||
if response["files"]:
|
msg += f'<h4>{len(response["files"])} Results : {fileName}</h4><br><br>'
|
||||||
msg += f'<h4>{len(response["files"])} Results : {fileName}</h4><br><br>'
|
|
||||||
for file in response.get('files', []):
|
|
||||||
if file.get(
|
|
||||||
'mimeType') == "application/vnd.google-apps.folder": # Detect Whether Current Entity is a Folder or File.
|
|
||||||
furl = f"https://drive.google.com/drive/folders/{file.get('id')}"
|
|
||||||
msg += f"⁍<code>{file.get('name')}<br>(folder)📁</code><br>"
|
|
||||||
if SHORTENER is not None and SHORTENER_API is not None:
|
|
||||||
sfurl = requests.get(
|
|
||||||
'https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, furl)).text
|
|
||||||
msg += f"<b><a href={sfurl}>Drive Link</a></b>"
|
|
||||||
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")}/')
|
|
||||||
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>"
|
|
||||||
if SHORTENER is not None and SHORTENER_API is not None:
|
|
||||||
sfurl = requests.get(
|
|
||||||
'https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, furl)).text
|
|
||||||
msg += f"<b><a href={sfurl}>Drive Link</a></b>"
|
|
||||||
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")}')
|
|
||||||
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>'
|
|
||||||
msg += '<br><br>'
|
|
||||||
content_count += 1
|
|
||||||
if content_count == TELEGRAPHLIMIT:
|
|
||||||
self.telegraph_content.append(msg)
|
|
||||||
msg = ""
|
|
||||||
content_count = 0
|
|
||||||
if msg != '':
|
|
||||||
self.telegraph_content.append(msg)
|
|
||||||
if len(self.telegraph_content) == 0:
|
|
||||||
return "No Result Found ❌", None
|
|
||||||
for content in self.telegraph_content:
|
|
||||||
self.path.append(Telegraph(access_token=TELEGRAPH_TOKEN).create_page(
|
|
||||||
title='Slam Mirror Bot Search',
|
|
||||||
author_name='Slam Mirror Bot',
|
|
||||||
author_url='https://github.com/breakdowns/slam-mirrorbot',
|
|
||||||
html_content=content
|
|
||||||
)['path'])
|
|
||||||
self.num_of_path = len(self.path)
|
|
||||||
if self.num_of_path > 1:
|
|
||||||
self.edit_telegraph()
|
|
||||||
msg = f"<b>🔎 Search Results For <i>{fileName}</i></b> \n<b>📚 Found {len(response['files'])} results</b>"
|
|
||||||
buttons = button_build.ButtonMaker()
|
|
||||||
buttons.buildbutton("HERE", f"https://telegra.ph/{self.path[0]}")
|
|
||||||
return msg, InlineKeyboardMarkup(buttons.build_menu(1))
|
|
||||||
else:
|
|
||||||
return '', ''
|
|
||||||
if not USE_TELEGRAPH:
|
|
||||||
for file in response.get('files', []):
|
for file in response.get('files', []):
|
||||||
if file.get(
|
if file.get('mimeType') == "application/vnd.google-apps.folder": # Detect Whether Current Entity is a Folder or File.
|
||||||
'mimeType') == "application/vnd.google-apps.folder": # Detect Whether Current Entity is a Folder or File.
|
furl = f"https://drive.google.com/drive/folders/{file.get('id')}"
|
||||||
msg += f"⁍ <a href='https://drive.google.com/drive/folders/{file.get('id')}'>{file.get('name')}" \
|
msg += f"⁍<code>{file.get('name')}<br>(folder)📁</code><br>"
|
||||||
f"</a> (folder)"
|
if SHORTENER is not None and SHORTENER_API is not None:
|
||||||
|
sfurl = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, furl)).text
|
||||||
|
msg += f"<b><a href={sfurl}>Drive Link</a></b>"
|
||||||
|
else:
|
||||||
|
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 = requests.utils.requote_uri(f'{INDEX_URL}/{file.get("name")}/')
|
||||||
msg += f' | <a href="{url}"> Index URL</a>'
|
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:
|
else:
|
||||||
msg += f"⁍ <a href='https://drive.google.com/uc?id={file.get('id')}" \
|
furl = f"https://drive.google.com/uc?id={file.get('id')}&export=download"
|
||||||
f"&export=download'>{file.get('name')}</a> ({get_readable_file_size(int(file.get('size')))})"
|
msg += f"⁍<code>{file.get('name')}<br>({get_readable_file_size(int(file.get('size')))})📄</code><br>"
|
||||||
|
if SHORTENER is not None and SHORTENER_API is not None:
|
||||||
|
sfurl = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, furl)).text
|
||||||
|
msg += f"<b><a href={sfurl}>Drive Link</a></b>"
|
||||||
|
else:
|
||||||
|
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 = requests.utils.requote_uri(f'{INDEX_URL}/{file.get("name")}')
|
||||||
msg += f' | <a href="{url}"> Index URL</a>'
|
if SHORTENER is not None and SHORTENER_API is not None:
|
||||||
msg += '\n'
|
siurl = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, url)).text
|
||||||
return msg, ''
|
msg += f' <b>| <a href="{siurl}">Index Link</a></b>'
|
||||||
|
else:
|
||||||
|
msg += f' <b>| <a href="{url}">Index Link</a></b>'
|
||||||
|
msg += '<br><br>'
|
||||||
|
content_count += 1
|
||||||
|
if content_count == TELEGRAPHLIMIT :
|
||||||
|
self.telegraph_content.append(msg)
|
||||||
|
msg = ""
|
||||||
|
content_count = 0
|
||||||
|
|
||||||
|
if msg != '':
|
||||||
|
self.telegraph_content.append(msg)
|
||||||
|
|
||||||
|
if len(self.telegraph_content) == 0:
|
||||||
|
return "No Result Found ❌", None
|
||||||
|
|
||||||
|
for content in self.telegraph_content :
|
||||||
|
self.path.append(Telegraph(access_token=telegraph_token).create_page(
|
||||||
|
title = 'Slam Mirror Bot Search',
|
||||||
|
author_name='Slam Mirror Bot',
|
||||||
|
author_url='https://github.com/breakdowns/slam-mirrorbot',
|
||||||
|
html_content=content
|
||||||
|
)['path'])
|
||||||
|
|
||||||
|
self.num_of_path = len(self.path)
|
||||||
|
if self.num_of_path > 1:
|
||||||
|
self.edit_telegraph()
|
||||||
|
|
||||||
|
msg = f"<b>🔎 Search Results For <i>{fileName}</i></b> \n<b>📚 Found {len(response['files'])} results</b>"
|
||||||
|
buttons = button_build.ButtonMaker()
|
||||||
|
buttons.buildbutton("HERE", f"https://telegra.ph/{self.path[0]}")
|
||||||
|
|
||||||
|
return msg, InlineKeyboardMarkup(buttons.build_menu(1))
|
||||||
|
|
||||||
|
else :
|
||||||
|
return '', ''
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,28 @@
|
||||||
from telegram.ext import CommandHandler, run_async
|
from telegram.ext import CommandHandler, run_async
|
||||||
from bot.helper.mirror_utils.upload_utils.gdriveTools import GoogleDriveHelper
|
from bot.helper.mirror_utils.upload_utils.gdriveTools import GoogleDriveHelper
|
||||||
from bot import LOGGER, dispatcher
|
from bot import LOGGER, dispatcher
|
||||||
from bot.helper.telegram_helper.message_utils import sendMessage, editMessage
|
from bot.helper.telegram_helper.message_utils import sendMessage, sendMarkup, editMessage
|
||||||
from bot.helper.telegram_helper.filters import CustomFilters
|
from bot.helper.telegram_helper.filters import CustomFilters
|
||||||
|
import threading
|
||||||
from bot.helper.telegram_helper.bot_commands import BotCommands
|
from bot.helper.telegram_helper.bot_commands import BotCommands
|
||||||
|
|
||||||
|
|
||||||
@run_async
|
@run_async
|
||||||
def list_drive(update, context):
|
def list_drive(update,context):
|
||||||
if update.message.text == f'/{BotCommands.ListCommand}':
|
try:
|
||||||
sendMessage(f'Send a search key along with {BotCommands.ListCommand} command', context.bot, update)
|
search = update.message.text.split(' ',maxsplit=1)[1]
|
||||||
else:
|
LOGGER.info(f"Searching: {search}")
|
||||||
search = update.message.text.split(' ', maxsplit=1)[1]
|
reply = sendMessage('Searching..... Please wait!', context.bot, update)
|
||||||
LOGGER.info(f"Searching: '{search}'...")
|
|
||||||
reply = sendMessage('Searching..... Please Wait!', context.bot, update)
|
|
||||||
gdrive = GoogleDriveHelper(None)
|
gdrive = GoogleDriveHelper(None)
|
||||||
msg, button = gdrive.drive_list(search)
|
msg, button = gdrive.drive_list(search)
|
||||||
if msg:
|
|
||||||
if button:
|
if button:
|
||||||
editMessage(msg, reply, button)
|
editMessage(msg, reply, button)
|
||||||
else:
|
|
||||||
editMessage(msg, reply)
|
|
||||||
else:
|
else:
|
||||||
editMessage('No results found', reply)
|
editMessage('No result found', reply, button)
|
||||||
# if not USE_TELEGRAPH:
|
|
||||||
# threading.Thread(target=auto_delete_message, args=(context.bot, update.message, reply)).start()
|
except IndexError:
|
||||||
|
sendMessage('Send a search key along with command', context.bot, update)
|
||||||
|
|
||||||
|
|
||||||
list_handler = CommandHandler(BotCommands.ListCommand, list_drive, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user)
|
list_handler = CommandHandler(BotCommands.ListCommand, list_drive,filters=CustomFilters.authorized_chat | CustomFilters.authorized_user)
|
||||||
dispatcher.add_handler(list_handler)
|
dispatcher.add_handler(list_handler)
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ TELEGRAM_HASH = ""
|
||||||
AUTHORIZED_CHATS = ""
|
AUTHORIZED_CHATS = ""
|
||||||
USE_SERVICE_ACCOUNTS = ""
|
USE_SERVICE_ACCOUNTS = ""
|
||||||
INDEX_URL = ""
|
INDEX_URL = ""
|
||||||
USE_TELEGRAPH = ""
|
|
||||||
UPTOBOX_TOKEN = ""
|
UPTOBOX_TOKEN = ""
|
||||||
MEGA_API_KEY = ""
|
MEGA_API_KEY = ""
|
||||||
MEGA_EMAIL_ID = ""
|
MEGA_EMAIL_ID = ""
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue