From a1649bc50fae037a0c96426196576f6c22fdfff7 Mon Sep 17 00:00:00 2001 From: Mystery0 Date: Wed, 6 Dec 2023 22:58:51 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9README?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 10 ++++++++++ bot/bot.go | 8 +++++--- publisher/publisher.go | 4 ++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 4e635eb..2c5cb28 100644 --- a/README.md +++ b/README.md @@ -47,11 +47,21 @@ bot: id: "" # 需要过滤的频道消息,这里可以填上对应的标签,例如:["tag1", "tag2"],那么就会过滤任何包含 “#tag1”、“#tag2” 的消息 filter: [ ] + reply: + # 是否启用处理回执,如果启用,那么会在处理完消息之后,会发送一条处理结果 + enable: true + # 回执自动删除时间,单位为秒,如果不需要自动删除,可以设置为0,如果启用了回执,那么会在指定时间之后自动删除回执 + delay: 10 private: # 是否启用私聊消息的处理 enable: true # 指定用户id,如果指定,那么只有对应用户的消息才会被处理,如果不指定,那么所有用户的消息都会被处理 sender: "" + reply: + # 是否启用处理回执,如果启用,那么会在处理完消息之后,会发送一条处理结果 + enable: true + # 回执自动删除时间,单位为秒,如果不需要自动删除,可以设置为0,如果启用了回执,那么会在指定时间之后自动删除回执 + delay: 10 log: home: "logs" diff --git a/bot/bot.go b/bot/bot.go index 32f0f92..370b902 100644 --- a/bot/bot.go +++ b/bot/bot.go @@ -45,9 +45,11 @@ func ReceiveMessage() <-chan tgbot.Update { } func DeleteMessage(chatId int64, messageId int, delayTime int) { - time.Sleep(time.Duration(delayTime) * time.Second) - if resp, err := bot.Request(tgbot.NewDeleteMessage(chatId, messageId)); err != nil || !resp.Ok { - logrus.Warnf("Error delete message, resp: %s, err: %v", string(resp.Result), err) + if delayTime > 0 { + time.Sleep(time.Duration(delayTime) * time.Second) + if resp, err := bot.Request(tgbot.NewDeleteMessage(chatId, messageId)); err != nil || !resp.Ok { + logrus.Warnf("Error delete message, resp: %s, err: %v", string(resp.Result), err) + } } } diff --git a/publisher/publisher.go b/publisher/publisher.go index 7576f4c..450c92d 100644 --- a/publisher/publisher.go +++ b/publisher/publisher.go @@ -56,8 +56,8 @@ func replySuccess(post model.Post) { return } logrus.Debugf("reply success message to telegram, delay time: %d", delayTime) - if delayTime <= 0 { - delayTime = 1 + if delayTime < 0 { + delayTime = 0 } if delayTime > 60 { delayTime = 60