-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
107 lines (93 loc) · 3.49 KB
/
Copy pathinstall.sh
File metadata and controls
107 lines (93 loc) · 3.49 KB
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
#!/usr/bin/env bash
set -e
REPO_RAW_URL="https://raw.githubusercontent.com/roon9e/tgifts/main"
echo "======================================================"
echo " Telegram Gifts & NFT Downloader Setup (Bash) "
echo "======================================================"
# 1. Initialize npm project and dependencies silently
if [ ! -f "package.json" ]; then
echo "[-] Initializing package.json..."
npm init -y > /dev/null 2>&1
fi
echo "[-] Installing dependencies..."
npm install teleproto input socks dotenv --loglevel=error --no-audit --no-fund > /dev/null 2>&1
# 2. Setup .gitignore
if [ ! -f ".gitignore" ]; then
cat << 'EOF' > .gitignore
.env
*.session
regular_gifts/
nft_models/
node_modules/
EOF
echo "[-] Created .gitignore"
fi
# 3. Check for local fetch.js first; download from GitHub if missing
if [ -f "fetch.js" ]; then
echo "[-] Found local fetch.js, skipping remote download."
else
echo "[-] Local fetch.js not found. Downloading from repository..."
if ! curl -fsSL "${REPO_RAW_URL}/fetch.js" -o fetch.js; then
echo "[!] Failed to download fetch.js from repository."
echo "[!] Please ensure fetch.js is pushed to GitHub or placed in this directory."
exit 1
fi
fi
# 4. Interactive .env Setup (if not already existing)
if [ ! -f ".env" ]; then
echo ""
echo "======================================================"
echo " API CREDENTIALS REQUIRED "
echo "======================================================"
echo "Obtain your credentials from https://my.telegram.org"
echo "under 'API development tools'."
echo ""
echo "--- TIP FOR RUSSIAN NUMBERS (+7) ---"
echo "Telegram requires your IP to match your phone's country (no foreign VPNs)."
echo "If my.telegram.org fails to open due to ISP DNS blocks, bypass it via hosts:"
echo " Linux/macOS: sudo nano /etc/hosts"
echo " Add line: 149.154.167.220 my.telegram.org"
echo "======================================================"
echo ""
# Explicitly read from /dev/tty so curl | bash works without EOF aborts
read -p "Enter API_ID: " INPUT_API_ID < /dev/tty || true
if [ -z "$INPUT_API_ID" ]; then
echo "[!] API_ID cannot be empty. Aborting setup."
exit 1
fi
read -p "Enter API_HASH: " INPUT_API_HASH < /dev/tty || true
if [ -z "$INPUT_API_HASH" ]; then
echo "[!] API_HASH cannot be empty. Aborting setup."
exit 1
fi
read -p "Enter Phone Number (e.g. +79...): " PHONE_NUMBER < /dev/tty || true
read -p "Enter 2FA Password (leave empty if none): " PASSWORD_2FA < /dev/tty || true
read -p "Use SOCKS5 Proxy? (y/N) [default: N]: " USE_PROXY_CHOICE < /dev/tty || true
if [[ "$USE_PROXY_CHOICE" =~ ^[Yy]$ ]]; then
USE_PROXY="true"
read -p "Enter Proxy IP [default: 127.0.0.1]: " INPUT_PROXY_IP < /dev/tty || true
PROXY_IP=${INPUT_PROXY_IP:-127.0.0.1}
read -p "Enter Proxy Port [default: 1080]: " INPUT_PROXY_PORT < /dev/tty || true
PROXY_PORT=${INPUT_PROXY_PORT:-1080}
else
USE_PROXY="false"
PROXY_IP="127.0.0.1"
PROXY_PORT="1080"
fi
cat <<EOF > .env
API_ID=$INPUT_API_ID
API_HASH=$INPUT_API_HASH
PHONE_NUMBER=$PHONE_NUMBER
PASSWORD_2FA=$PASSWORD_2FA
USE_PROXY=$USE_PROXY
PROXY_IP=$PROXY_IP
PROXY_PORT=$PROXY_PORT
DOWNLOAD_MODE=3
SESSION_STRING=
EOF
echo "[-] Saved credentials to .env"
fi
# 5. Run Scraper with TTY preserved
echo ""
echo "[-] Starting downloader..."
node fetch.js < /dev/tty