- Telegram Account.
- Heroku Account.
- Github Account.
- Install Python on Windows.
- Google Drive Account.
Repo Link: Here
In this guide, we will deploy our mirror bot on heroku using github action. keep this thing in mind that deploying mirror bot on heroku may result in suspension of the heroku account.
If you starting fresh, then this guide will easily take your 1-2 hours.
Ok then lets start.
Click Here
- First thing first, goto bot repo Click Here and fork the bot repo.
- Now download that repo.
- The downloaded repo will be in zip file, so extract it.
Click Here
- Goto your google cloud console. Click Here
- Create a new project (if you already have a project then no need to create another one)
- Now select the project you just create.
- Now search for drive api and enable it.
- After enabling drive api, goto your oauth consent screen
cloud console home screen
>hamburger menu on the left
>api and services
>oauth consen screen
- Once the oauth consent screen app is published, now we can create the credentials.json
- And done now download your .json file.
- After download rename it to
credentials.json
, make sure you have enabled "file name extensions" because most users basically rename credentials.json to credentials.json.json without knowing.
-
Make sure that its credentials.json and not credentials.json.json.
-
Now move that credentials.json file to the extracted repo folder.
- We have sucessfully created our credentials.json file.
Click Here
- For generating token.pickle you will need python.
- So install python from this link Click Here. (while installing, make sure that
add to the path
option is selected.) - Once installed, open cmd and run
python --version
to make that you have installed python correctly.
- Ok, now goto your extracted repo folder click on the address bar and type cmd then hit enter.
- There you go.
- Now give command
pip install google-api-python-client google-auth-httplib2 google-auth-oauthlib
- Now for the next command make sure to set a default browser, in my case chrome is the default.
- Then run
python generate_drive_token.py
- One browser window will open, just follow the on screen prompt.
- Now after you reach this screen.
- token.pickle will be available in the extracted repo folder.
Click Here
- Now we need to host our token.pickle
- For that we will use google drive index.
- This is the repo we will be using for our google drive index.
- Go to this link.
- Sign in to get the Authentication Code.
- Paste that code in
Authentication Code
var.
- For
Site Name
var, you can give any name for egpersonal
. - For
Share Drive ID or root
var, goto your drive and create a new folder for your index (don't create this folder in the shared drive).
- Go inside that folder and copy the id of that folder.
- Use it for
Share Drive ID or root
var.
- Then click on submit and copy the genrated code for your index.
- Now goto cloudflare and sign up for an account.
- Then goto
workers
- Then complete the verification process and come back to the
workers
section again.
- Remove all the default content from here.
- And paste the code u genrated for your index then click on
save and deploy
.
- Now wait for 10 seconds your index will be online.
- Then go here and save the link for your index, it will come handy later.
- Now goto that drive folder u create for the index and upload your token.pickle
- Then open your index link click on
drive one
you will see your token.pickle file u just uploaded.
-
We successfully hosted our token.pickle in our index. (Just dont share this index link, as it has confidential file.)
Click Here
- Go here and copy all the content.
- Then goto Github Gist
- Give your gist a name
config.env
- And paste the previously copied content here
- Now remove line no 2.
_____REMOVE_THIS_LINE_____=True
- Then start filling the config vars.
- For now i will only show the necessary config values for the proper working of the mirror leech bot.
BOT_TOKEN:
- Search @BotFather on telegram, start the bot and send
/newbot
then follow the on screen instruction to create a new bot.
- This will be the value of BOT_TOKEN
GDRIVE_FOLDER_ID:
- Search @MSGuite_SD_Creator_Bot on telegram, start the bot click on
genrate td
now send your email address, give your drive a good name for eghitesh920's drive
and done. - Now go inside the shared drive you just created by
google drive
>shared drive
>the shared drive you created
.
- Now copy the root id of your shared drive
- For eg https://drive.google.com/drive/folders/xxxxxxxxxxx then the code after
folders/
will be the your root id
- This will be the value of GDRIVE_FOLDER_ID
OWNER_ID:
- Search @MissRose_bot on telegram, start the bot then type
/id
bot will send your account's id - Use that for OWNER_ID
DOWNLOAD_DIR:
- Keep the default values, no need to change anything here.
DOWNLOAD_STATUS_UPDATE_INTERVAL:
- Keep the default values, no need to change anything here.
AUTO_DELETE_MESSAGE_DURATION:
- Keep the default values, no need to change anything here.
IS_TEAM_DRIVE:
- Set this to
True
as we are using shared drive.
TELEGRAM_API & TELEGRAM_HASH:
- Go here and register with your number connected to telegram account fill with your number , choose desktop, fill app title and short name to any name you want.
- Then goto https://my.telegram.org/apps
- This will give the values of
TELEGRAM_API
andTELEGRAM_HASH
App api_id
will be your TELEGRAM_API
App api_hash
will be your TELEGRAM_HASH
TOKEN_PICKLE_URL:
- Go to your index link and click on the token.pickle u just hosted in step 4 and copy the direct download link.
- And use that url for TOKEN_PICKLE_URL
BASE_URL_OF_BOT:
https://yourappname.herokuapp.com
, suppose if my heroku app name is hitesh920-mirrorbot then the BASE_URL_OF_BOT will be https://hitesh920-mirrorbot.herokuapp.com
UPSTREAM_REPO:
- Your forked repository link, if your repo is private add
https://username:{githubtoken}@github.com/{username}/{reponame}
format. Get token from Github settings. So your bot can update from filled repository on each restart.
UPSTREAM_BRANCH:
- Upstream branch for update. Empty means
master
.
We are done with the all necessary configs for the proper working of your mirror leech bot.
It should look like this after filling all the necessary values
- Then click on create secret gist to save the gist.
- We have successfully created our config.env
Click Here
- Goto your forked repo > settings > secrets > action
Now here under secrets, you need to create four secrets
- HEROKU_EMAIL
- HEROKU_API_KEY
- HEROKU_APP_NAME
- CONFIG_FILE_URL
Do the same for other three secrets.
- Goto your heroku account settings Here
- Scroll down and copy the api key
- Name you would like to give to your heroku app (must be unique)
-
Goto that gist you created for the config.env
-
Then click on raw
- And copy the url then remove the commit id
- For eg
https://gist.githubusercontent.com/ghostmirrorlab/f9b1e6xxxxxxxxxxxxxaaac04520/raw/200d4a93e0eb5ee8d4b0e5a377ce0396a131843e/config.env
then the commit id will the one afterraw/
and before/config.env
original config.env url
:
https://gist.githubusercontent.com/ghostmirrorlab/f9b1e6xxxxxxxxxxxxxaaac04520/raw/200d4a93e0eb5ee8d4b0e5a377ce0396a131843e/config.env
url after removing commit id
:
https://gist.githubusercontent.com/ghostmirrorlab/f9b1e6xxxxxxxxxxxxxaaac04520/raw/config.env
- After removing the commit id use that url for the CONFIG_FILE_URL
- Once all the four secrets have been added, it should look like this
- And we are done with the action secrets.
Click Here
We will use github action to deploy bot.
- Goto your
forked repo
>action
- Now your workflow will start, deploy will take arround 3-4 minutes.
- You can check the workflow logs at
- Once deployment done
- Goto your heroku account, click on the app you just created then click on more and then click on view logs.
- Wait for few seconds your bot will start if your config.env is correct.
- Now search the username of the bot u created with @BotFather and start the bot
- And done, congratulations.
- To use service account follow the
sa
branch or just Click Here - If you want to update your bot then just do
/restart
or you can also turn dynos off and on from your heroku app. - If you want to update config.env then goto your config.env gist > edit > save > then
/restart
the bot. - If you want to redeploy the bot then just goto heroku website then delete the app you deployed and follow the step 7 and start the workflow again.
- To know more about all the optional configs then read the README.md file of the bot repo.
- To set bot commands, then you can use @BotFather using
/setcommands
. All the commands are listed in the README.md file of the bot repo. - Want to ask something els? Join Mirror Socity.