-
Notifications
You must be signed in to change notification settings - Fork 524
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
103 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
#!/usr/bin/env bash | ||
|
||
|
||
# COLORS # | ||
# COLORS | ||
White="\033[1;37m" | ||
Red="\033[1;31m" | ||
Cyan="\033[1;36m" | ||
Yellow="\033[1;93m" | ||
Green="\033[1;32m" | ||
Un_Purple="\033[4;35m" | ||
|
@@ -15,13 +16,13 @@ declare -A pkgs_git=([apt]=git-all [pacman]=git [dnf]=git-all) | |
declare -A pkgs_pip=([apt]=python3-pip [pacman]=python-pip [dnf]=python3-pip) | ||
|
||
|
||
# Output functions # | ||
# Output functions | ||
function show_process() { | ||
echo -e "${White}==> ${1}${Reset}" | ||
} | ||
|
||
function show_hint() { | ||
echo -e " 💡: ${Yellow}${1}${Reset}" | ||
echo -e " Tip 💡: ${Yellow}${1}${Reset}" | ||
} | ||
|
||
function show_error() { | ||
|
@@ -87,19 +88,13 @@ function clone_repo() { | |
# Check dependencies | ||
function check_deps() { | ||
show_process "Checking dependencies 🔍" | ||
|
||
is_git=$(command -v git &> /dev/null) | ||
is_pip3=$(command -v pip3 &> /dev/null) | ||
is_ffmpeg=$(command -v ffmpeg &> /dev/null) | ||
is_megatools=$(command -v megatools &> /dev/null) | ||
|
||
if ! $is_git ; then | ||
if ! command -v git &> /dev/null ; then | ||
pkg_installer ${pkgs_git[$PKGMN]} | ||
elif ! $is_pip3 ; then | ||
elif ! command -v pip3 &> /dev/null ; then | ||
pkg_installer ${pkgs_pip[$PKGMN]} | ||
elif ! $is_ffmpeg ; then | ||
elif ! command -v ffmpeg &> /dev/null ; then | ||
pkg_installer ffmpeg | ||
elif ! $is_megatools ; then | ||
elif ! command -v megatools &> /dev/null ; then | ||
pkg_installer megatools | ||
fi | ||
|
||
|
@@ -122,36 +117,101 @@ function gen_env() { | |
read -p "Enter your API HASH: " api_hash | ||
read -p "Enter your BOT TOKEN: " bot_token | ||
|
||
# Mega account | ||
# read mega.nz email and password with default values | ||
def_mail="[email protected]" | ||
def_pass="strong#password" | ||
read -p "Enter your Mega.nz Email [$def_mail]: " mega_email | ||
mega_email=${mega_email:-def_mail} | ||
read -p "Enter your Mega.nz Passsword [$def_pass]: " mega_password | ||
mega_password=${mega_password:-def_pass} | ||
mega_email="" | ||
mega_password="" | ||
private_bot=false | ||
while true; do | ||
read -p "Do you want to create private bot with pre-configured mega account? [y/n]" add_mega | ||
case $add_mega in | ||
y|yes|Y|Yes ) private_bot=true; break;; | ||
* ) private_bot=false; break;; | ||
esac | ||
done | ||
if $private_bot ; then | ||
read -p "Enter your Mega.nz Email [$def_mail]: " mega_email | ||
mega_email="MEGA_EMAIL=${mega_email:-def_mail}" | ||
read -p "Enter your Mega.nz Passsword [$def_pass]: " mega_password | ||
mega_password="MEGA_PASSWORD=${mega_password:-def_pass}" | ||
fi | ||
|
||
# read authorized users in to a variable called auth_users | ||
# if auth_users are empty set to "*" otherwise check if private_bot var is set to true | ||
# if the private_bot var is set to true then auth_users will be the input otherwise it will be "*|<user input>" | ||
read -p "Enter authorized users (seperate with space) [empty for all users]: " auth_users | ||
auth_users=${auth_users:-"*"} | ||
if $private_bot ; then | ||
auth_users="$auth_users" | ||
else | ||
auth_users="*|$auth_users" | ||
fi | ||
|
||
touch .env | ||
# add log chat | ||
log_chat="" | ||
while true; do | ||
read -p "Do you want to see user activity logs? [y/n]" see_logs | ||
case $see_logs in | ||
y|yes|Y|Yes ) see_logs=true; break;; | ||
* ) see_logs=false; break;; | ||
esac | ||
done | ||
|
||
if $see_logs ; then | ||
read -p "Enter a chat id where bot is an admin [preferably a channel]: " log_chat | ||
log_chat="LOG_CHAT=${log_chat}" | ||
fi | ||
|
||
|
||
# add mongodb url | ||
mongo_url="" | ||
while true; do | ||
read -p "Do you want to setup mongodb? [y/n]" set_mongo | ||
case $set_mongo in | ||
y|yes|Y|Yes ) set_mongo=true; break;; | ||
* ) set_mongo=false; break;; | ||
esac | ||
done | ||
|
||
if $set_mongo ; then | ||
read -p "Enter the mongodb url [more info: https://t.ly/YxYXq]: " mongo_url | ||
mongo_url="MONGO_URI=${mongo_url}" | ||
fi | ||
|
||
|
||
# generate cypher key | ||
cypher_key=$(python3 -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())") | ||
|
||
|
||
touch .env || echo "" > .env | ||
cat <<EOF >> .env | ||
APP_ID=$api_id | ||
API_HASH=$api_hash | ||
BOT_TOKEN=$bot_token | ||
USE_ENV=True | ||
MEGA_EMAIL=$mega_email | ||
MEGA_PASSWORD=$mega_password | ||
$mega_email | ||
$mega_password | ||
USE_ENV=False | ||
AUTH_USERS=$auth_users | ||
$log_chat | ||
$mongo_url | ||
CYPHER_KEY=$cypher_key | ||
DOWNLOAD_LOCATION=${PWD}/NexaBots | ||
DOWNLOAD_LOCATION="${PWD}"/NexaBots | ||
CHUNK_SIZE=524288 | ||
TG_MAX_SIZE=2040108421 | ||
EOF | ||
|
||
show_hint "If your bot won't work as expected, try reassigning USE_ENV and DOWNLOAD_LOCATION in .env file" | ||
show_hint "If your bot won't work as expected, try reassigning USE_ENV and DOWNLOAD_LOCATION in .env file. Not sure what to do? Contact support at @Nexa_bots" | ||
} | ||
|
||
|
||
function run_installer() { | ||
echo -e "${White}${Un_Purple}Welcome to ${Red}Mega.nz-Bot${Reset}${White}${Un_Purple} Setup!${Reset}" | ||
echo -e "${White}${Un_Purple}Welcome to ${Red}Mega.nz-Bot${Reset}${White}${Un_Purple} - ${Cyan}Cypher${Reset}${White}${Un_Purple} Setup!${Reset}" | ||
|
||
exit | ||
setup_env | ||
clone_repo | ||
check_deps | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[Login] | ||
Username = [email protected] | ||
Password = your-password | ||
|
||
[Network] | ||
# 10240 = 10MiB/s | ||
SpeedLimit = 10240 | ||
Proxy = socks5://127.0.0.1:9050 | ||
ParallelTransfers = 8 | ||
|
||
[Cache] | ||
# 120 = 2min | ||
Timeout=120 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters