forked from Itz-fork/Mega.nz-Bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstaller.sh
184 lines (146 loc) · 4.89 KB
/
installer.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#!/usr/bin/bash
# Colors
White="\033[1;37m"
Red="\033[1;31m"
Green="\033[1;32m"
Reset="\033[0m"
function show_process_msg() {
echo -e "$White ==> $1 $Reset"
}
function show_success_msg() {
echo -e "\n${Green}Successfully finished$Reset$White ${1}$Reset${Green}!$Reset"
}
function show_error_msg() {
echo -e "$Red ERROR: $1 $Reset"
if [[ ! $2 == "n" ]]; then
exit
fi
}
echo -e "$White
Mega.nz-Bot Installer - v1.1
"
function install_git() {
sudo apt install git-all ||
sudo pacman -S git ||
sudo dnf install git ||
show_error_msg "Your system deosn't match the current list of Oses. Please install 'git' from - https://git-scm.com/book/en/v2/Getting-Started-Installing-Git"
}
function install_pip3() {
sudo apt install python3-pip ||
sudo pacman -S python-pip ||
sudo dnf install python3-pip ||
show_error_msg "Your system deosn't match the current list of Oses. Please install 'pip3' from - https://pip.pypa.io/en/stable/installation/"
}
function _aur_megatools() {
git clone https://aur.archlinux.org/megatools.git
cd megatools || show_error_msg "megatools dir doesn't exists rn! Tf did you do?"
makepkg -si
cd ..
rm -rf megatools
}
function install_megatools() {
sudo apt install megatools ||
_aur_megatools ||
sudo dnf install megatools ||
show_error_msg "Your system deosn't match the current list of Oses. Please install 'megatools' from - https://megatools.megous.com/"
}
function checkDepends() {
show_process_msg "Checking dependencies"
is_git=$(command -v git &> /dev/null)
is_ffmpeg=$(command -v ffmpeg &> /dev/null)
is_pip3=$(command -v pip3 &> /dev/null)
is_megatools=$(command -v megatools &> /dev/null)
# Checks if git is installed
if ! $is_git ; then
show_process_msg "Installing git"
install_git
# Checks if ffmpeg is installed
elif ! $is_ffmpeg ; then
show_process_msg "Installing ffmpeg"
curl -sS https://webinstall.dev/ffmpeg | bash ||
show_error_msg "Ffmpeg is not installed. Visit - https://ffmpeg.org/download.html"
# Checks if pip3 is installed
elif ! $is_pip3 ; then
show_process_msg "Installing pip3"
install_pip3
# Checks if megatools is installed
elif ! $is_megatools ; then
show_process_msg "Installing megatools"
install_megatools
fi
}
function install() {
show_process_msg "Cloning into Mega.nz-Bot repository"
git clone https://github.com/Itz-fork/Mega.nz-Bot || show_error_msg "Unable to clone the Mega.nz-Bot repository"
show_process_msg "Changing the directory to 'Mega.nz-Bot'"
cd Mega.nz-Bot || show_error_msg "'Mega.nz-Bot' folder not found"
show_process_msg "Installing Requirements using pip3"
pip3 install -U -r requirements.txt &> /dev/null || show_error_msg "Unable to install requirements"
show_success_msg "Installation"
}
function genConfig() {
show_process_msg "Generating config file"
# Mandotory vars
read -p "Enter your API ID: " api_id
read -p "Enter your API HASH: " api_hash
read -p "Enter your BOT TOKEN: " bot_token
read -p "Enter Telegram IDs of Auth users (Seperate by a space): " auth_users
read -p "Enter your LOG CHANNEL ID: " log_channel_id
# Optional vars
while true; do
read -p "Do you want to make your bot public? (y/n) " is_pb
case $is_pb in
y|Y)
is_public="True"
break; shift ;;
n|N)
is_public="False"
break; shift ;;
*)
show_error_msg "Invalid option - $is_pb !" "n"
esac
done
while true; do
read -p "Do you want to setup mega account credentials? (y/n) " is_mauth
case $is_mauth in
y|Y)
read -p "Enter your Mega.nz Email: " mega_email
read -p "Enter your Mega.nz Passsword: " mega_password
break; shift;;
n|N)
break; shift ;;
*)
show_error_msg "Invalid option - $is_mauth !" "n";;
esac
done
echo "" > config.py
cat <<EOF >> config.py
# Copyright 2022 - Itz-fork
# Generated by Mega.nz Installer
class Config(object):
APP_ID = $api_id
API_HASH = "$api_hash"
BOT_TOKEN = "$bot_token"
AUTH_USERS = set(int(x) for x in "$auth_users".split(" "))
IS_PUBLIC_BOT = $is_public
LOGS_CHANNEL = $log_channel_id
# DON'T CHANGE THESE 2 VARS
DOWNLOAD_LOCATION = "./NexaBots"
TG_MAX_SIZE = 2040108421
# Mega User Account
MEGA_EMAIL = "$mega_email"
MEGA_PASSWORD = "$mega_password"
EOF
show_success_msg "Generating config file"
}
function run_bot() {
show_process_msg "Starting the bot"
python3 -m megadl
}
function main() {
checkDepends
install
genConfig
run_bot
}
main