diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..a2973f4 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,10 @@ +.git +.venv +__pycache__ +*.pyc +*.pyo +*.pyd +*.sqlite3 +*.sqlite3-* +*.log +memory.md diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..5c3e5df --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM python:3.12-slim + +ENV PYTHONDONTWRITEBYTECODE=1 \ + PYTHONUNBUFFERED=1 + +WORKDIR /app + +COPY requirements.txt /app/requirements.txt +RUN pip install --no-cache-dir -r /app/requirements.txt + +COPY . /app + +EXPOSE 8765 + +CMD ["python", "app.py"] diff --git a/README.md b/README.md index d8af791..7cd1fc8 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,39 @@ tg-watchbot 是一个轻量级 Python 服务,把 **Telegram 双向客服机器 项目为单文件应用,适合个人服务器、NAT 小鸡、轻量 VPS 直接用 systemd 跑。 +
+

tg-watchbot

+

Telegram 双向客服机器人 + Web/RSS 监控推送 + 可视化管理面板

+

双向对话 · 关键词监控 · 私聊广告拦截 · 多管理员 · 配置导入导出

+

+ AI 一句话安装 · + Docker 安装 · + 手动安装 · + systemd 部署 · + 面板路由 · + 更新日志 +

+
+ + +## AI 一句话安装 + +```bash +bash -lc 'git clone https://github.com/GongyiChuren/tg-watchbot.git tg-watchbot && cd tg-watchbot && cp -n .env.example .env && cp -n config.example.yaml config.yaml && touch tg-watchbot.sqlite3 tg-watchbot.log && docker compose up -d --build' +``` + +说明:默认走 Docker(`restart: unless-stopped`,重启后自动拉起)。首次启动后打开 `http://127.0.0.1:8765`,在面板里填写 Token / 管理员 ID,保存后重启容器生效: + +```bash +docker compose restart +``` + +### AI 一句话直接安装(非 Docker) + +```bash +bash -lc 'git clone https://github.com/GongyiChuren/tg-watchbot.git tg-watchbot && cd tg-watchbot && python3 -m venv .venv && ./.venv/bin/pip install -U pip && ./.venv/bin/pip install -r requirements.txt && cp -n .env.example .env && cp -n config.example.yaml config.yaml && ./.venv/bin/python app.py' +``` + ## 更新日志 ### 2026-05-21 第二次更新 @@ -109,8 +142,34 @@ tg-watchbot 是一个轻量级 Python 服务,把 **Telegram 双向客服机器 - 如果要把面板暴露到公网,建议使用 Cloudflare Access / 反代鉴权,并使用强密码。 - Bot 只能给“已经主动私聊过 Bot 的用户”发消息,这是 Telegram Bot API 的限制。 + ## 快速开始(推荐使用systemd 部署) + +## Docker 安装(含自启) + +```bash +git clone https://github.com/GongyiChuren/tg-watchbot.git tg-watchbot +cd tg-watchbot +cp .env.example .env +cp config.example.yaml config.yaml +touch tg-watchbot.sqlite3 tg-watchbot.log +docker compose up -d --build +``` + +查看状态与日志: + +```bash +docker compose ps +docker compose logs -f +``` + +修改配置后重启: + +```bash +docker compose restart +``` + ```bash git clone https://github.com/GongyiChuren/tg-watchbot.git tg-watchbot cd tg-watchbot @@ -148,6 +207,7 @@ http://127.0.0.1:8765 ./.venv/bin/python app.py --run-once ``` + ## systemd 部署 推荐部署到 `/opt/tg-watchbot`: diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..07efb15 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,13 @@ +services: + tg-watchbot: + build: . + container_name: tg-watchbot + restart: unless-stopped + ports: + - "8765:8765" + env_file: + - .env + volumes: + - ./config.yaml:/app/config.yaml + - ./tg-watchbot.sqlite3:/app/tg-watchbot.sqlite3 + - ./tg-watchbot.log:/app/tg-watchbot.log