fix: adjust message deletion timing and handle private chat cases

This commit is contained in:
purofle 2025-04-13 15:37:40 +08:00
parent e12ee332d8
commit 9bf6d3d9a4
No known key found for this signature in database
2 changed files with 26 additions and 3 deletions

View File

@ -1,4 +1,4 @@
FROM golang:latest as build
FROM golang:latest AS build
WORKDIR /src

View File

@ -96,7 +96,11 @@ func CommandRemake(c tele.Context) error {
return err
}
time.AfterFunc(3*time.Second, func() {
if c.Chat().Type == tele.ChatPrivate {
return nil
}
time.AfterFunc(5*time.Second, func() {
err = c.Bot().Delete(reply)
err = c.Bot().Delete(msg)
if err != nil {
@ -107,6 +111,9 @@ func CommandRemake(c tele.Context) error {
}
func CommandRemakeData(c tele.Context) error {
msg := c.Message()
var text string
userData, hasKey := remakeCount[c.Sender().ID]
if hasKey {
@ -115,7 +122,23 @@ func CommandRemakeData(c tele.Context) error {
text = "您还没有 remake 过呢,快 /remake 吧"
}
return c.Reply(text)
reply, err := c.Bot().Reply(msg, text)
if err != nil {
return err
}
if c.Chat().Type == tele.ChatPrivate {
return nil
}
time.AfterFunc(10*time.Second, func() {
err = c.Bot().Delete(reply)
err = c.Bot().Delete(msg)
if err != nil {
return
}
})
return nil
}
func CommandEat(c tele.Context) error {