diff --git a/README.md b/README.md
index f0b1d64..580ea3a 100644
--- a/README.md
+++ b/README.md
@@ -3,13 +3,9 @@
## [English](#english-version) | [简体中文](#rss-to-telegram-bot-使用文档)
#
->
-> [!TIP]
-> ***简称rss2tg,用于将自定义RSS地址,字段,刷新时间里的相关帖子即时发送到自定义TG用户或频道,省去你刷帖子的时间***
-> ***支持AMD64/ARM64***
-> ***镜像大小17M,内存占用10M***
-> **——By [drfyup](https://hstz.com)**
->
+
+> [!TIP] > **_简称 rss2tg,用于将自定义 RSS 地址,字段,刷新时间里的相关帖子即时发送到自定义 TG 用户或频道,省去你刷帖子的时间_**
> **_支持 AMD64/ARM64_**
> **_镜像大小 17M,内存占用 10M_**
> **——By [drfyup](https://hstz.com)**
+
#
## 1. 部署方法
@@ -28,16 +24,16 @@ git clone https://github.com/3377/rss2tg.git
4. 编辑 `docker-compose.yml` 文件,修改环境变量:
--- 进入任意目录或直接当前目录,新建docker-compose.yml文件,填入以下内容
+-- 进入任意目录或直接当前目录,新建 docker-compose.yml 文件,填入以下内容
```yaml
-version: '3'
+version: "3"
services:
rss2tg:
container_name: rss2tg
image: drfyup/rss2tg:latest
volumes:
- - ./config:/app/config
+ - ./config/config.yaml:/app/config/config.yaml
- ./data:/app/data
environment:
- TELEGRAM_BOT_TOKEN=your_bot_token_here
@@ -67,15 +63,15 @@ docker pull drfyup/rss2tg:latest
```yaml
docker run -d \
- --name rss2tg \
- -v $(pwd)/config:/app/config \
- -v $(pwd)/data:/app/data \
- -e TELEGRAM_BOT_TOKEN=your_bot_token_here \
- -e TELEGRAM_USERS=user_id_1,user_id_2 \
- -e TELEGRAM_CHANNELS=@channel_1,@channel_2 \
- -e TZ=Asia/Shanghai \
- --restart unless-stopped \
- drfyup/rss2tg:latest
+--name rss2tg \
+-v $(pwd)/config:/app/config \
+-v $(pwd)/data:/app/data \
+-e TELEGRAM_BOT_TOKEN=your_bot_token_here \
+-e TELEGRAM_USERS=user_id_1,user_id_2 \
+-e TELEGRAM_CHANNELS=@channel_1,@channel_2 \
+-e TZ=Asia/Shanghai \
+--restart unless-stopped \
+drfyup/rss2tg:latest
```
请替换环境变量中的相应值。
@@ -138,28 +134,28 @@ Bot 支持以下命令:
#### 方式二
-在当前config目录下新建config.ymal,填入以下内容。
+在当前 config 目录下新建 config.ymal,填入以下内容。
```yaml
rss:
-- url: https://rss.nodeseek.com
- interval: 30
- keywords:
- - vps
- - 甲骨文
- - 免费
- group: NS论坛
-- url: https://linux.do/latest.rss
- interval: 30
- keywords:
- - vps
- - 甲骨文
- - 免费
- - 龟壳
- group: LC论坛
+ - url: https://rss.nodeseek.com
+ interval: 30
+ keywords:
+ - vps
+ - 甲骨文
+ - 免费
+ group: NS论坛
+ - url: https://linux.do/latest.rss
+ interval: 30
+ keywords:
+ - vps
+ - 甲骨文
+ - 免费
+ - 龟壳
+ group: LC论坛
```
-***两种方式都可以,系统会每1分钟自动检测,即使动态更改生效。***
+**_两种方式都可以,系统会每 1 分钟自动检测,即使动态更改生效。_**
### 2.4 编辑 RSS 订阅
@@ -204,13 +200,14 @@ docker logs rss2tg
![image](https://github.com/user-attachments/assets/4e9ac180-5eb1-40a8-98e1-03b9fa68b691)
# English Version
+
# RSS to Telegram Bot usage documentation
+
#
-> [!TIP]
->*** Referred to as rss2tg, it is used to instantly send related posts in custom RSS addresses, fields, and refresh times to custom TG users or channels, eliminating the time for you to swipe posts.***
->*** Support AMD64/ARM64***
->*** Image size 17M, memory footprint 10M***
-> **——By [drfyup](https://hstz.com)**
+
+> [!TIP] >**_ Referred to as rss2tg, it is used to instantly send related posts in custom RSS addresses, fields, and refresh times to custom TG users or channels, eliminating the time for you to swipe posts._**
>**_ Support AMD64/ARM64_**
>**_ Image size 17M, memory footprint 10M_**
+> **——By [drfyup](https://hstz.com)**
+
#
## 1. Deployment method
@@ -232,7 +229,7 @@ git clone https://github.com/3377/rss2tg.git
-- Enter any directory or directly the current directory and create a new docker-compose.yml file, fill in the following content
```yaml
-version: '3'
+version: "3"
services:
rss2tg:
container_name: rss2tg
@@ -268,15 +265,15 @@ docker pull drfyup/rss2tg:latest
```yaml
docker run -d \
- --name rss2tg \
- -v $(pwd)/config:/app/config \
- -v $(pwd)/data:/app/data \
- -e TELEGRAM_BOT_TOKEN=your_bot_token_here \
- -e TELEGRAM_USERS=user_id_1,user_id_2 \
- -e TELEGRAM_CHANNELS=@channel_1,@channel_2 \
- -e TZ=Asia/Shanghai \
- --restart unless-stopped \
- drfyup/rss2tg:latest
+--name rss2tg \
+-v $(pwd)/config:/app/config \
+-v $(pwd)/data:/app/data \
+-e TELEGRAM_BOT_TOKEN=your_bot_token_here \
+-e TELEGRAM_USERS=user_id_1,user_id_2 \
+-e TELEGRAM_CHANNELS=@channel_1,@channel_2 \
+-e TZ=Asia/Shanghai \
+--restart unless-stopped \
+drfyup/rss2tg:latest
```
Please replace the corresponding value in the environment variable.
@@ -318,14 +315,7 @@ rss:
The Bot supports the following commands:
--`/start`-Start using the robot
--`/help`-Get help information
--`/config`-View current configuration
--`/add`-add RSS subscription
--`/edit`-edit RSS feed
--`/delete`-delete RSS feed
--`/list`-list all RSS feeds
--`/statistics`-View push statistics
+-`/start`-Start using the robot -`/help`-Get help information -`/config`-View current configuration -`/add`-add RSS subscription -`/edit`-edit RSS feed -`/delete`-delete RSS feed -`/list`-list all RSS feeds -`/statistics`-View push statistics
### 2.3 Add RSS feed
@@ -359,7 +349,8 @@ rss:
-Turtle shell
group: LC Forum
```
-***Both methods are possible, the system will automatically detect every 1 minute, even if the dynamic changes take effect.***
+
+**_Both methods are possible, the system will automatically detect every 1 minute, even if the dynamic changes take effect._**
### 2.4 Edit RSS feed
diff --git a/README.pdf b/README.pdf
new file mode 100644
index 0000000..4f70b1b
Binary files /dev/null and b/README.pdf differ
diff --git a/internal/bot/bot.go b/internal/bot/bot.go
index 82a151f..2a5f2ec 100644
--- a/internal/bot/bot.go
+++ b/internal/bot/bot.go
@@ -71,16 +71,10 @@ func (b *Bot) Start() {
log.Println("机器人已启动")
commands := []tgbotapi.BotCommand{
- {Command: "start", Description: "开始使用机器人并查看帮助信息"},
- {Command: "config", Description: "查看当前配置"},
- {Command: "add", Description: "添加RSS订阅"},
- {Command: "add_all", Description: "向所有订阅添加关键词"},
- {Command: "del_all", Description: "从所有订阅删除关键词"},
- {Command: "edit", Description: "编辑RSS订阅"},
- {Command: "delete", Description: "删除RSS订阅"},
- {Command: "list", Description: "列出所有RSS订阅"},
- {Command: "stats", Description: "查看推送统计"},
- {Command: "version", Description: "获取当前版本信息"},
+ {Command: "start", Description: "开始/帮助"},
+ {Command: "view", Description: "查看类命令"},
+ {Command: "edit", Description: "编辑类命令"},
+ {Command: "stats", Description: "推送统计"},
}
setMyCommandsConfig := tgbotapi.NewSetMyCommands(commands...)
@@ -106,24 +100,12 @@ func (b *Bot) Start() {
switch update.Message.Command() {
case "start":
b.handleStart(chatID)
- case "config":
- b.handleConfig(chatID)
- case "add":
- b.handleAdd(chatID, userID)
- case "add_all":
- b.handleAddAll(chatID, userID)
- case "del_all":
- b.handleDelAll(chatID, userID)
- case "edit":
- b.handleEdit(chatID, userID)
- case "delete":
- b.handleDelete(chatID, userID)
- case "list":
- b.handleList(chatID)
case "stats":
b.handleStats(chatID)
- case "version":
- b.handleVersion(chatID)
+ case "view":
+ b.handleView(chatID, userID)
+ case "edit":
+ b.handleEdit(chatID, userID)
default:
b.sendMessage(chatID, "未知命令,请使用 /start 查看可用命令。")
}
@@ -143,7 +125,7 @@ func (b *Bot) SendMessage(title, url, group string, pubDate time.Time, matchedKe
boldKeywords[i] = "*#" + keyword + "*"
}
- text := fmt.Sprintf("*%s*\n\n*🌐 链接:*%s\n\n*🔍 关键词:*%s\n\n*🏷️ 分组:*%s\n\n*🕒 时间:*%s",
+ text := fmt.Sprintf("*%s*\n\n🌐 链接:*%s*\n\n🔍 关键词:*%s*\n\n🏷️ 分组:*%s*\n\n🕒 时间:*%s*",
title,
url,
strings.Join(boldKeywords, " "),
@@ -187,40 +169,54 @@ func (b *Bot) reloadConfig() error {
}
func (b *Bot) handleStart(chatID int64) {
- // 更新命令列表
- commands := []tgbotapi.BotCommand{
- {Command: "start", Description: "开始使用机器人并查看帮助信息"},
- {Command: "config", Description: "查看当前配置"},
- {Command: "add", Description: "添加RSS订阅"},
- {Command: "add_all", Description: "向所有订阅添加关键词"},
- {Command: "del_all", Description: "从所有订阅删除关键词"},
- {Command: "edit", Description: "编辑RSS订阅"},
- {Command: "delete", Description: "删除RSS订阅"},
- {Command: "list", Description: "列出所有RSS订阅"},
- {Command: "stats", Description: "查看推送统计"},
- {Command: "version", Description: "获取当前版本信息"},
- }
-
- setMyCommandsConfig := tgbotapi.NewSetMyCommands(commands...)
- if _, err := b.api.Request(setMyCommandsConfig); err != nil {
- log.Printf("更新命令列表失败: %v", err)
- }
-
helpText := `欢迎使用RSS订阅机器人!
-可用命令:
-/config - 查看当前配置
-/add - 添加RSS订阅
-/add_all - 向所有订阅添加关键词
-/del_all - 从所有订阅删除关键词
-/edit - 编辑RSS订阅
-/delete - 删除RSS订阅
-/list - 列出所有RSS订阅
+主要命令:
+/start - 开始使用机器人并查看帮助信息
/stats - 查看推送统计
-/version - 获取当前版本信息`
+/view - 查看类命令合集
+/edit - 编辑类命令合集
+
+查看类命令(使用 /view 选择):
+1 - 查看当前配置
+2 - 查看推送统计
+3 - 列出所有RSS订阅
+4 - 获取当前版本信息
+
+编辑类命令(使用 /edit 选择):
+1 - 添加RSS订阅
+2 - 编辑RSS订阅
+3 - 删除RSS订阅
+4 - 向所有订阅添加关键词
+5 - 从所有订阅删除关键词`
b.sendMessage(chatID, helpText)
}
+func (b *Bot) handleView(chatID int64, userID int64) {
+ text := `请选择要执行的查看命令:
+1 - 查看当前配置
+2 - 查看推送统计
+3 - 列出所有RSS订阅
+4 - 获取当前版本信息
+
+请输入命令编号(1-4):`
+ b.userState[userID] = "view_command"
+ b.sendMessage(chatID, text)
+}
+
+func (b *Bot) handleEdit(chatID int64, userID int64) {
+ text := `请选择要执行的编辑命令:
+1 - 添加RSS订阅
+2 - 编辑RSS订阅
+3 - 删除RSS订阅
+4 - 向所有订阅添加关键词
+5 - 从所有订阅删除关键词
+
+请输入命令编号(1-5):`
+ b.userState[userID] = "edit_command"
+ b.sendMessage(chatID, text)
+}
+
func (b *Bot) handleConfig(chatID int64) {
if err := b.reloadConfig(); err != nil {
b.sendMessage(chatID, "加载配置时出错:" + err.Error())
@@ -268,6 +264,37 @@ func (b *Bot) handleUserInput(message *tgbotapi.Message) {
text := message.Text
switch b.userState[userID] {
+ case "view_command":
+ switch text {
+ case "1":
+ b.handleConfig(chatID)
+ case "2":
+ b.handleStats(chatID)
+ case "3":
+ b.handleList(chatID)
+ case "4":
+ b.handleVersion(chatID)
+ default:
+ b.sendMessage(chatID, "无效的命令编号,请使用 /view 重新选择。")
+ }
+ delete(b.userState, userID)
+ case "edit_command":
+ switch text {
+ case "1":
+ b.handleAdd(chatID, userID)
+ case "2":
+ b.handleEdit(chatID, userID)
+ case "3":
+ b.handleDelete(chatID, userID)
+ case "4":
+ b.handleAddAll(chatID, userID)
+ case "5":
+ b.handleDelAll(chatID, userID)
+ default:
+ b.sendMessage(chatID, "无效的命令编号,请使用 /edit 重新选择。")
+ delete(b.userState, userID)
+ return
+ }
case "add_url":
b.userState[userID] = "add_interval"
b.config.RSS = append(b.config.RSS, struct {
diff --git a/version b/version
index b4efa15..58e9161 100644
--- a/version
+++ b/version
@@ -1,2 +1,2 @@
-2.1-24.12.17
+2.1-24.12.18