Skip to content

Commit

Permalink
fix: 修改README
Browse files Browse the repository at this point in the history
  • Loading branch information
Mystery00 committed Dec 6, 2023
1 parent f02ffb6 commit a1649bc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 5 additions & 3 deletions bot/bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions publisher/publisher.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a1649bc

Please sign in to comment.