Added AUTHORIZED_CHATS in config & auto generate String Session (#3)
* Added AUTHORIZED_CHATS in config * Update config_sample.env * Update app.json * Update __init__.py * Update config_sample.env * Delete generate_string_session.py * Update app.json * Delete authorized_chats.txt * Oof * Update README.md * Forget * Update README.md * Update README.md
This commit is contained in:
parent
c7b58b09cd
commit
b8aac403b3
21
README.md
21
README.md
|
|
@ -5,18 +5,9 @@ This is a telegram bot writen in python for mirroring files on the internet to o
|
|||
|
||||
Fork of [python-aria-mirror-bot](https://github.com/lzzy12/python-aria-mirror-bot/)
|
||||
|
||||
Original Source [Ayanamileechbot](https://gitlab.com/Dank-del/ayanamileechbot)
|
||||
Original Source [Ayanamileechbot](https://gitlab.com/Dank-del/ayanamileechbot/)
|
||||
|
||||
## Installing requirements
|
||||
- Clone this repo:
|
||||
```
|
||||
git clone https://github.com/breakdowns/slam-mirrorbot mirrorbot/
|
||||
cd mirrorbot
|
||||
```
|
||||
- Generate session string by running:
|
||||
```
|
||||
python3 generate_string_session.py
|
||||
```
|
||||
Some features from [magneto-python-aria](https://github.com/magneto261290/magneto-python-aria/)
|
||||
|
||||
## Getting Google OAuth API credential file
|
||||
|
||||
|
|
@ -25,6 +16,11 @@ python3 generate_string_session.py
|
|||
- Go to the Credentials tab and click Create Credentials -> OAuth Client ID
|
||||
- Choose Desktop and Create.
|
||||
- Use the download button to download your credentials.
|
||||
- Clone this repo:
|
||||
```
|
||||
git clone https://github.com/breakdowns/slam-mirrorbot mirrorbot/
|
||||
cd mirrorbot
|
||||
```
|
||||
- Move that file to the root of mirrorbot, and rename it to credentials.json
|
||||
- Visit [Google API page](https://console.developers.google.com/apis/library)
|
||||
- Search for Drive and enable it if it is disabled
|
||||
|
|
@ -37,6 +33,3 @@ python3 generate_drive_token.py
|
|||
## Deploying on Heroku
|
||||
|
||||
<p><a href="https://heroku.com/deploy?template=https://github.com/breakdowns/slam-mirrorbot"> <img src="https://www.herokucdn.com/deploy/button.svg" alt="Deploy to Heroku" /></a></p>
|
||||
|
||||
Heroku Note: Doing authorizations ( /authorize command ) through telegram wont be permanent as heroku uses ephemeral filesystem. They will be reset on each dyno boot. As a workaround you can:
|
||||
- Edit a [authorized_chats.txt](https://github.com/breakdowns/slam-mirrorbot/blob/master/authorized_chats.txt) file and write the user_id and chat_id of you want to authorize, each separated by new line
|
||||
|
|
|
|||
8
app.json
8
app.json
|
|
@ -49,6 +49,10 @@
|
|||
"description": "Whether to use service accounts or not. For this to work see 'Using service accounts' section below.",
|
||||
"required": false
|
||||
},
|
||||
"AUTHORIZED_CHATS": {
|
||||
"description": "Put user_id and chat_id of you want to authorize.",
|
||||
"required": false
|
||||
},
|
||||
"INDEX_URL": {
|
||||
"description": "Refer to https://github.com/maple3142/GDIndex/ The URL should not have any trailing '/'.",
|
||||
"required": false
|
||||
|
|
@ -60,10 +64,6 @@
|
|||
"TELEGRAM_HASH": {
|
||||
"description": "This is to authenticate to your telegram account for downloading Telegram files. You can get this from https://my.telegram.org.",
|
||||
"required": true
|
||||
},
|
||||
"USER_SESSION_STRING": {
|
||||
"description": "Session string generated by running: python3 generate_string_session.py.",
|
||||
"required": true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
|
||||
|
|
@ -2,10 +2,10 @@ import logging
|
|||
import os
|
||||
import threading
|
||||
import time
|
||||
from pyrogram import Client
|
||||
import aria2p
|
||||
import telegram.ext as tg
|
||||
from dotenv import load_dotenv
|
||||
from pyrogram import Client
|
||||
import socket
|
||||
|
||||
socket.setdefaulttimeout(600)
|
||||
|
|
@ -64,6 +64,14 @@ if os.path.exists('authorized_chats.txt'):
|
|||
for line in lines:
|
||||
# LOGGER.info(line.split())
|
||||
AUTHORIZED_CHATS.add(int(line.split()[0]))
|
||||
try:
|
||||
achats = getConfig('AUTHORIZED_CHATS')
|
||||
achats = achats.split(" ")
|
||||
for chats in achats:
|
||||
AUTHORIZED_CHATS.add(int(chats))
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
BOT_TOKEN = getConfig('BOT_TOKEN')
|
||||
parent_id = getConfig('GDRIVE_FOLDER_ID')
|
||||
|
|
@ -73,12 +81,15 @@ try:
|
|||
DOWNLOAD_STATUS_UPDATE_INTERVAL = int(getConfig('DOWNLOAD_STATUS_UPDATE_INTERVAL'))
|
||||
OWNER_ID = int(getConfig('OWNER_ID'))
|
||||
AUTO_DELETE_MESSAGE_DURATION = int(getConfig('AUTO_DELETE_MESSAGE_DURATION'))
|
||||
USER_SESSION_STRING = getConfig('USER_SESSION_STRING')
|
||||
TELEGRAM_API = getConfig('TELEGRAM_API')
|
||||
TELEGRAM_HASH = getConfig('TELEGRAM_HASH')
|
||||
except KeyError as e:
|
||||
LOGGER.error("One or more env variables missing! Exiting now")
|
||||
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()
|
||||
try:
|
||||
INDEX_URL = getConfig('INDEX_URL')
|
||||
if len(INDEX_URL) == 0:
|
||||
|
|
@ -102,7 +113,7 @@ try:
|
|||
USE_SERVICE_ACCOUNTS = False
|
||||
except KeyError:
|
||||
USE_SERVICE_ACCOUNTS = False
|
||||
app = Client('ayanami', api_id=TELEGRAM_API, api_hash=TELEGRAM_HASH, bot_token=BOT_TOKEN)
|
||||
app = Client('slam', api_id=TELEGRAM_API, api_hash=TELEGRAM_HASH, bot_token=BOT_TOKEN)
|
||||
updater = tg.Updater(token=BOT_TOKEN,use_context=True)
|
||||
bot = updater.bot
|
||||
dispatcher = updater.dispatcher
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ DOWNLOAD_STATUS_UPDATE_INTERVAL = 5
|
|||
AUTO_DELETE_MESSAGE_DURATION = 20
|
||||
IS_TEAM_DRIVE = ""
|
||||
INDEX_URL = ""
|
||||
USER_SESSION_STRING = ""
|
||||
TELEGRAM_API =
|
||||
TELEGRAM_HASH = ""
|
||||
USE_SERVICE_ACCOUNTS = ""
|
||||
AUTHORIZED_CHATS = ""
|
||||
|
|
|
|||
|
|
@ -1,6 +0,0 @@
|
|||
from pyrogram import Client
|
||||
|
||||
API_KEY = int(input("Enter API KEY: "))
|
||||
API_HASH = input("Enter API HASH: ")
|
||||
with Client(':memory:', api_id=API_KEY, api_hash=API_HASH) as app:
|
||||
print(app.export_session_string())
|
||||
Loading…
Reference in New Issue