-
Notifications
You must be signed in to change notification settings - Fork 2
chore: merge dev to master #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
2a0ab87
faf8b07
2241bde
83b2b7f
1d072e8
90d62b6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,28 +58,33 @@ skip - 跳过说明 | |
|
|
||
| ## ⚡ 快速开始(Docker) | ||
|
|
||
| 1) 创建 `docker-compose.yml` | ||
|
|
||
| ```yaml | ||
| services: | ||
| rule-bot: | ||
| image: aethersailor/rule-bot:latest | ||
| container_name: rule-bot | ||
| restart: unless-stopped | ||
| environment: | ||
| - TELEGRAM_BOT_TOKEN=你的机器人 Token | ||
| - GITHUB_TOKEN=你的 GitHub Token | ||
| - GITHUB_REPO=your_username/your_repository | ||
| - DIRECT_RULE_FILE=rule/Custom_Direct.list | ||
| 1) 创建工作目录并下载配置文件 | ||
|
|
||
| ```bash | ||
| mkdir -p /opt/Rule-Bot && cd /opt/Rule-Bot | ||
| wget https://raw.githubusercontent.com/Aethersailor/Rule-Bot/main/docker-compose.yml | ||
| ``` | ||
|
|
||
| 2) 启动 | ||
| 1) 编辑配置文件 | ||
|
|
||
| ```bash | ||
| vim docker-compose.yml | ||
| ``` | ||
|
|
||
| 修改以下必填参数(去掉 `#` 注释,填入你的实际值): | ||
|
|
||
| - `TELEGRAM_BOT_TOKEN` | ||
| - `GITHUB_TOKEN` | ||
| - `GITHUB_REPO` | ||
| - `DIRECT_RULE_FILE` | ||
|
|
||
| 1) 启动容器 | ||
|
|
||
| ```bash | ||
| docker compose up -d | ||
| ``` | ||
|
|
||
| 3) 查看日志 | ||
| 1) 查看日志 | ||
|
|
||
| ```bash | ||
| docker compose logs -f rule-bot | ||
|
|
@@ -113,6 +118,7 @@ docker compose logs -f rule-bot | |
| | `REQUIRED_GROUP_NAME` | 群组验证名称 | 空 | | ||
| | `REQUIRED_GROUP_LINK` | 群组验证链接 | 空 | | ||
| | `ALLOWED_GROUP_IDS` | 群组模式允许的群组 ID,逗号分隔 | 空 | | ||
| | `ADMIN_USER_IDS` | 管理员 Telegram 用户 ID,逗号分隔 | 空 | | ||
| | `TZ` | 时区 | `Asia/Shanghai` | | ||
|
|
||
| </details> | ||
|
|
@@ -142,6 +148,15 @@ docker compose logs -f rule-bot | |
|
|
||
| 同时配置 `REQUIRED_GROUP_ID/NAME/LINK` 后生效,未通过或校验失败会拒绝访问(失败即拒绝)。 | ||
|
|
||
| ### 管理员模式(ADMIN_USER_IDS) | ||
|
|
||
| 配置 `ADMIN_USER_IDS` 后,指定的管理员用户可以: | ||
|
|
||
| - 强制添加被系统检测拒绝的域名 | ||
| - 获取调试辅助信息 | ||
|
||
|
|
||
| > 通过 @userinfobot 获取你的 Telegram 用户 ID。 | ||
|
|
||
| ## 📌 规则逻辑(简版) | ||
|
|
||
| 1) 解析域名并提取二级域名 | ||
|
|
@@ -160,6 +175,7 @@ docker compose logs -f rule-bot | |
| ## 🧩 常见问题 | ||
|
|
||
| **群组不响应消息** | ||
|
|
||
| 1. 关闭 Privacy Mode | ||
| 2. 重新添加机器人到群组 | ||
| 3. 仅在消息中 @ 机器人 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |
| """ | ||
|
|
||
| import os | ||
| import re | ||
| from typing import Optional, Dict | ||
| from loguru import logger | ||
|
|
||
|
|
@@ -47,6 +48,14 @@ def __init__(self): | |
| # 群组工作模式配置(允许机器人在这些群组中直接响应 @提及) | ||
| # 支持逗号分隔的多个群组 ID,例如:-1001234567890,-1009876543210 | ||
| self.ALLOWED_GROUP_IDS = self._parse_group_ids(os.getenv("ALLOWED_GROUP_IDS", "")) | ||
|
|
||
| # 管理员配置(Telegram 用户 ID 列表) | ||
| # 支持逗号分隔的多个用户 ID,例如:123456789,987654321 | ||
| self.ADMIN_USER_IDS = self._parse_user_ids(os.getenv("ADMIN_USER_IDS", "")) | ||
| if self.ADMIN_USER_IDS: | ||
| logger.info(f"已加载管理员 IDs: {self.ADMIN_USER_IDS}") | ||
| else: | ||
| logger.info("未配置管理员 IDs(ADMIN_USER_IDS)") | ||
|
|
||
| # 数据源URL | ||
| # 使用 Aethersailor GeoIP 数据库 | ||
|
|
@@ -120,6 +129,29 @@ def _parse_group_ids(self, ids_str: str) -> list: | |
| logger.warning(f"无效的 ALLOWED_GROUP_IDS: {raw_id}") | ||
| return group_ids | ||
|
|
||
| def _parse_user_ids(self, ids_str: str) -> list: | ||
| """解析用户 ID 列表 | ||
|
|
||
| Args: | ||
| ids_str: 逗号分隔的用户 ID 字符串 | ||
|
|
||
| Returns: | ||
| 用户 ID 整数列表 | ||
| """ | ||
| if not ids_str.strip(): | ||
| return [] | ||
|
|
||
| user_ids = [] | ||
| parts = [part for part in re.split(r"[,\s;]+", ids_str.strip()) if part] | ||
| for raw_id in parts: | ||
| if not raw_id: | ||
| continue | ||
| try: | ||
| user_ids.append(int(raw_id)) | ||
| except ValueError: | ||
| logger.warning(f"无效的 ADMIN_USER_IDS: {raw_id}") | ||
| return user_ids | ||
|
Comment on lines
+132
to
+153
|
||
|
|
||
| def _parse_required_group_id(self, group_id_raw: str) -> Optional[int]: | ||
| """解析必需群组 ID""" | ||
| if not group_id_raw: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The numbering in the Quick Start section is incorrect. All steps are numbered as "1)" instead of being sequentially numbered (1, 2, 3, 4). This makes the documentation confusing to follow. The steps should be numbered: 1) 创建工作目录并下载配置文件, 2) 编辑配置文件, 3) 启动容器, 4) 查看日志