mirror of
https://github.com/purofle/remake_bot.git
synced 2025-04-29 14:43:30 +08:00
fix: adjust message deletion timing and handle private chat cases
This commit is contained in:
parent
e12ee332d8
commit
9bf6d3d9a4
@ -1,4 +1,4 @@
|
||||
FROM golang:latest as build
|
||||
FROM golang:latest AS build
|
||||
|
||||
WORKDIR /src
|
||||
|
||||
|
27
handlers.go
27
handlers.go
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user