File size: 4,887 Bytes
972b6f2 | 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 | #!/bin/bash
# TelegramGuard β One-line installer
# curl -sL https://raw.githubusercontent.com/ilang-ai/TelegramGuard/main/install.sh | bash
set -e
GREEN='\033[0;32m'
CYAN='\033[0;36m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m'
BOLD='\033[1m'
echo ""
echo -e "${CYAN}ββββββββββββββββββββββββββββββββββββββββββββββββββββ${NC}"
echo -e "${CYAN}β${NC} ${BOLD}TelegramGuard${NC} β AI Group Guardian ${CYAN}β${NC}"
echo -e "${CYAN}β${NC} Powered by I-Lang Prompt Spec ${CYAN}β${NC}"
echo -e "${CYAN}β${NC} https://ilang.ai ${CYAN}β${NC}"
echo -e "${CYAN}ββββββββββββββββββββββββββββββββββββββββββββββββββββ${NC}"
echo ""
# Check root
if [ "$EUID" -ne 0 ]; then
echo -e "${RED}Run as root: sudo bash install.sh${NC}"
exit 1
fi
# Check Python 3
if ! command -v python3 &> /dev/null; then
echo -e "${YELLOW}Installing Python 3...${NC}"
apt-get update -qq && apt-get install -y -qq python3 python3-pip python3-venv > /dev/null 2>&1
fi
echo -e "${GREEN}[1/5]${NC} Cloning TelegramGuard..."
INSTALL_DIR="/opt/TelegramGuard"
rm -rf "$INSTALL_DIR"
git clone -q https://github.com/ilang-ai/TelegramGuard.git "$INSTALL_DIR"
cd "$INSTALL_DIR"
echo -e "${GREEN}[2/5]${NC} Installing dependencies..."
python3 -m venv venv
source venv/bin/activate
pip install -q -r requirements.txt
echo -e "${GREEN}[3/5]${NC} Configuration"
echo ""
# Bot Token
echo -e "${BOLD}Telegram Bot Token${NC}"
echo -e " Get one: open Telegram β find ${CYAN}@BotFather${NC} β send ${CYAN}/newbot${NC}"
echo -e " Then send these to BotFather:"
echo -e " ${CYAN}/setjoingroups${NC} β Enable"
echo -e " ${CYAN}/setprivacy${NC} β Disable"
echo ""
read -p " Paste your Bot Token: " BOT_TOKEN
echo ""
# Gemini API Key
echo -e "${BOLD}Gemini API Key${NC} (free)"
echo -e " Get one: ${CYAN}https://aistudio.google.com/apikey${NC}"
echo ""
read -p " Paste your API Key: " GEMINI_API_KEY
echo ""
# Write env file
cat > "$INSTALL_DIR/.env" << EOF
BOT_TOKEN=$BOT_TOKEN
GEMINI_API_KEY=$GEMINI_API_KEY
DB_PATH=$INSTALL_DIR/data/bot.db
EOF
mkdir -p "$INSTALL_DIR/data"
echo -e "${GREEN}[4/5]${NC} Creating system service..."
cat > /etc/systemd/system/telegramguard.service << EOF
[Unit]
Description=TelegramGuard - AI Group Guardian
After=network.target
[Service]
Type=simple
User=root
WorkingDirectory=$INSTALL_DIR
EnvironmentFile=$INSTALL_DIR/.env
ExecStart=$INSTALL_DIR/venv/bin/python3 bot.py
Restart=always
RestartSec=5
Environment=PYTHONUNBUFFERED=1
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable telegramguard
echo -e "${GREEN}[5/5]${NC} Starting TelegramGuard..."
systemctl start telegramguard
sleep 2
if systemctl is-active --quiet telegramguard; then
echo ""
echo -e "${GREEN}ββββββββββββββββββββββββββββββββββββββββββββββββββββ${NC}"
echo -e "${GREEN}β${NC} ${BOLD}TelegramGuard is running!${NC} ${GREEN}β${NC}"
echo -e "${GREEN}β βββββββββββββββββββββββββββββββββββββββββββββββββββ£${NC}"
echo -e "${GREEN}β${NC} ${GREEN}β${NC}"
echo -e "${GREEN}β${NC} Open Telegram and message your bot. ${GREEN}β${NC}"
echo -e "${GREEN}β${NC} Add it to any group for auto spam protection. ${GREEN}β${NC}"
echo -e "${GREEN}β${NC} ${GREEN}β${NC}"
echo -e "${GREEN}β${NC} Commands: ${GREEN}β${NC}"
echo -e "${GREEN}β${NC} systemctl status telegramguard ${GREEN}β${NC}"
echo -e "${GREEN}β${NC} systemctl restart telegramguard ${GREEN}β${NC}"
echo -e "${GREEN}β${NC} journalctl -u telegramguard -f ${GREEN}β${NC}"
echo -e "${GREEN}β${NC} ${GREEN}β${NC}"
echo -e "${GREEN}β${NC} Customize: edit prompts_demo/*.ilang ${GREEN}β${NC}"
echo -e "${GREEN}β${NC} I-Lang Spec: ${CYAN}https://ilang.ai${NC} ${GREEN}β${NC}"
echo -e "${GREEN}β${NC} ${GREEN}β${NC}"
echo -e "${GREEN}ββββββββββββββββββββββββββββββββββββββββββββββββββββ${NC}"
else
echo -e "${RED}Something went wrong. Check: journalctl -u telegramguard -f${NC}"
fi
|