Skip to content

Commit 772fc5b

Browse files
committed
sleep
1 parent 39a2883 commit 772fc5b

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Java/Kotlin用户推荐使用 [spring-boot-starter](https://github.com/protobufb
88

99
支持发送的消息:文字、表情、图片、atQQ
1010

11+
有问题发issue,或者进QQ群335783090
12+
1113
## 验证码类型及处理方法
1214

1315
处理验证码时必须用到浏览器

service/bot/proto2mirai.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package bot
33
import (
44
"strconv"
55
"strings"
6+
"time"
67

78
"github.com/Mrs4s/MiraiGo/message"
89
"github.com/ProtobufBot/Go-Mirai-Client/pkg/util"
@@ -53,6 +54,8 @@ func ProtoMsgToMiraiMsg(msgList []*onebot.Message, notConvertText bool) []messag
5354
containReply = true
5455
messageChain = append([]message.IMessageElement{replyElement}, messageChain...)
5556
}
57+
case "sleep":
58+
ProtoSleep(protoMsg.Data)
5659
default:
5760
log.Errorf("不支持的消息类型 %+v", protoMsg)
5861
}
@@ -253,3 +256,21 @@ func ProtoReplyToMiraiReply(data map[string]string) *message.ReplyElement {
253256
}
254257
return nil
255258
}
259+
260+
func ProtoSleep(data map[string]string) {
261+
t, ok := data["time"]
262+
if !ok {
263+
log.Warnf("failed to get sleep time1")
264+
return
265+
}
266+
ms, err := strconv.Atoi(t)
267+
if err != nil {
268+
log.Warnf("failed to get sleep time2")
269+
return
270+
}
271+
if ms > 24*3600*1000 {
272+
log.Warnf("最多 sleep 24小时")
273+
ms = 24 * 3600 * 1000
274+
}
275+
time.Sleep(time.Duration(ms) * time.Millisecond)
276+
}

service/bot/raw2mirai.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ func RawMsgToMiraiMsg(str string) []message.IMessageElement {
6969
containReply = true
7070
elemList = append([]message.IMessageElement{replyElement}, elemList...)
7171
}
72+
case "sleep":
73+
ProtoSleep(attrMap)
7274
default:
7375
log.Warnf("不支持的类型 %s", code)
7476
elemList = append(elemList, message.NewText(code))

0 commit comments

Comments
 (0)