-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_telegrambot.sh
executable file
·82 lines (67 loc) · 1.64 KB
/
setup_telegrambot.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
#!/bin/bash
# Author: @saniyar_krmi
# Contact: @saniyar_dev (Telegram), [email protected]
RED="\033[31m" # Error message
GREEN="\033[32m" # Success message
YELLOW="\033[33m" # Warning message
BLUE="\033[36m" # Info message
PLAIN='\033[0m'
colorEcho() {
echo -e "${1}${@:2}${PLAIN}"
}
setupCommands() {
GIT_CMD="$(command -v git)"
YARN_CMD="$(command -v yarn)"
}
getProjectName() {
Counter=0
while [[ -z $PROJECT_NAME ]]; do
if (( $Counter > 0 )); then
colorEcho $RED "Don't leave this field empty!"
fi
read -p "Please enter your project name": PROJECT_NAME
Counter=$(($Counter + 1))
done
Counter=0
}
setupNode() {
bash <(curl -sL https://raw.githubusercontent.com/saniyar-dev/scripts/main/install_latest_node.sh)
}
installGit() {
colorEcho $RED "Please install git first."
updateCommands
}
getRepo() {
if [[ -z "$GIT_CMD" ]]; then
installGit
fi
git clone https://hamgit.ir/saniyar.dev/create-telegram-bot.git $PROJECT_NAME
cd $PROJECT_NAME
git remote remove origin
}
installPackages() {
$YARN_CMD install
}
setBotToken() {
Counter=0
while [[ -z $BOT_TOKEN ]]; do
if (( $Counter > 0 )); then
colorEcho $RED "Don't leave this field empty!"
fi
read -p "Please enter your bot token": BOT_TOKEN
Counter=$(($Counter + 1))
done
echo "BOT_TOKEN=\"$BOT_TOKEN\"" > .env
colorEcho $GREEN "BOT_TOKEN set successfully"
git add -A
git commit -m "add: BOT_TOKEN"
}
setupBot() {
getProjectName
getRepo
setBotToken
installPackages
}
setupNode
setupCommands
setupBot