forked from nameless3721/nash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtgbot.sh
66 lines (62 loc) · 1.6 KB
/
tgbot.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
#!/bin/bash
apt-get update -y
apt install -y python-pip git
# 安装路径
Path="/root"
# 管理员数字ID
Adminid="123456"
# 机器人Token
BotToken="1234:ABCD"
# Python的绝对路径
Pythonpath="/usr/bin/python"
if [ `command -v pip` ];then
echo 'pip 已经安装'
else
echo -e "\033[31m Error:未安装pip 请自行安装 \033[0m"
exit
fi
#安装
cd $Path
git clone https://github.com/610312586/Telegram-chatbot
cd $Path/Telegram-chatbot
pip install python-telegram-bot==11.1.0
mv config-default.json config.json
cat << EOF > ./config.json
{
"Admin": $Adminid,
"//1": "管理员用户ID(数字ID)(可以先不设)",
"Token": "$BotToken",
"//2": "机器人Token",
"Lang": "zh",
"//3": "语言包名称",
"manager8": 1,
"manager7": 1,
"manager6": 1,
"//6": "以上三行可以是最多三个管理员或者bot测试者、开发者"
}
EOF
# 建立服务
cat > /etc/systemd/system/tgbot.service <<EOF
[Unit]
Description=TGbot server
After=network.target
Wants=network.target
[Service]
Type=simple
PIDFile=/var/run/Tgbot.pid
ExecStart=$Pythonpath $Path/Telegram-chatbot/main.py
RestartPreventExitStatus=23
Restart=always
RestartSec=5
User=root
[Install]
WantedBy=multi-user.target
EOF
clear
# 资料
echo '##########################################################'
echo '#启动BOT:systemctl start tgbot'
echo '#开机启动:systemctl enable tgbot'
echo '#程序来自:https://github.com/610312586/Telegram-chatbot'
echo '#BOT指令文档:https://github.com/610312586/Telegram-chatbot/blob/master/README.md'
echo '##########################################################'