本文发布于 629 天前,部分信息可能随时间变化。
准备工作
- Deepseek API KEY:【点击进入】
- Telegram API KEY
- 搜索@BotFather——输入/start——选择/newbot——设置名称——设置机器人用户名(以_bot结尾)
- SSH连接工具Finalshell:【点击进入】
1、开源项目:【点击进入】
2、安装git
sudo apt update && sudo apt install git -y
3、克隆存储库
git clone https://github.com/slobys/DeepSeek-AI-Telegram-Bot.git
cd DeepSeek-AI-Telegram-Bot
4、安装python3-venv
sudo apt install python3-venv -y
5、创建虚拟环境并安装依赖
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
- 退出虚拟环境
deactivate
6、修改配置文件
- 进入/root/DeepSeek-AI-Telegram-Bot目录,打开bot.py文件,添加前面准备好的Telegram API KEY和Deepseek API KEY
7、进入/etc/systemd/system目录并创建telegram_bot.service服务文件
[Unit]
Description=Telegram Bot Service
After=network.target
[Service]
User=root
WorkingDirectory=/root/DeepSeek-AI-Telegram-Bot
ExecStart=/root/DeepSeek-AI-Telegram-Bot/venv/bin/python /root/DeepSeek-AI-Telegram-Bot/bot.py
Restart=always
[Install]
WantedBy=multi-user.target
8、服务管理命令
# 重新加载 systemd
sudo systemctl daemon-reload
# 启动 bot
sudo systemctl start telegram_bot
# 设置开机自启
sudo systemctl enable telegram_bot
# 查看日志(可选)
sudo journalctl -u telegram_bot -f










