Skip to content

Commit 139282c

Browse files
committed
go up
1 parent 41cf3e5 commit 139282c

File tree

4 files changed

+43
-45
lines changed

4 files changed

+43
-45
lines changed

go.mod

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
module github.com/ProtobufBot/Go-Mirai-Client
22

3-
go 1.17
3+
go 1.18
44

55
require (
6-
github.com/Mrs4s/MiraiGo v0.0.0-20220301053927-15a746802b1e
6+
github.com/Mrs4s/MiraiGo v0.0.0-20220318145114-35f774b86afa
77
github.com/fanliao/go-promise v0.0.0-20141029170127-1890db352a72
88
github.com/gin-gonic/gin v1.7.2
99
github.com/go-playground/validator/v10 v10.8.0 // indirect
@@ -31,12 +31,11 @@ require (
3131
)
3232

3333
require (
34-
github.com/RomiChan/protobuf v0.0.0-20220227114948-643565fff248 // indirect
34+
github.com/RomiChan/protobuf v0.0.0-20220318113238-d8a99598f896 // indirect
3535
github.com/fumiama/imgsz v0.0.2 // indirect
3636
github.com/gin-contrib/sse v0.1.0 // indirect
3737
github.com/go-playground/locales v0.13.0 // indirect
3838
github.com/go-playground/universal-translator v0.17.0 // indirect
39-
github.com/klauspost/compress v1.13.6 // indirect
4039
github.com/leodido/go-urn v1.2.1 // indirect
4140
github.com/modern-go/reflect2 v1.0.1 // indirect
4241
github.com/pierrec/lz4/v4 v4.1.11 // indirect

go.sum

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
2-
github.com/Mrs4s/MiraiGo v0.0.0-20220117165008-3b461554b747 h1:i9IcyQOVc3eYHXAXgTAMsEdAcGkxpbjBEvVb87z50ZA=
3-
github.com/Mrs4s/MiraiGo v0.0.0-20220117165008-3b461554b747/go.mod h1:rtKLkhMEi2YjsrXaNztT4uagUOPBxf6a+TNREkG097I=
4-
github.com/Mrs4s/MiraiGo v0.0.0-20220301053927-15a746802b1e h1:bm0sdUwEHqns9M1Xz5j8oVug2hTUAxCJMHnIK73eq0U=
5-
github.com/Mrs4s/MiraiGo v0.0.0-20220301053927-15a746802b1e/go.mod h1:23f5g1I7XT7mB3zq02B3rfuiDnE7PJYSfvb/skzDVhI=
6-
github.com/RomiChan/protobuf v0.0.0-20211223055824-048df49a8956 h1:hnaAkKz4t+xpSNVp5mnuloRMd3Rj2Lfg5biZ3emv//c=
7-
github.com/RomiChan/protobuf v0.0.0-20211223055824-048df49a8956/go.mod h1:CKKOWC7mBxd36zxsCB1V8DTrwlTNRQvkSVbYqyUiGEE=
8-
github.com/RomiChan/protobuf v0.0.0-20220227114948-643565fff248 h1:1jRB6xuBKwfgZrg0bA7XJin0VeNwG9iJKx9RXwDobt4=
9-
github.com/RomiChan/protobuf v0.0.0-20220227114948-643565fff248/go.mod h1:CKKOWC7mBxd36zxsCB1V8DTrwlTNRQvkSVbYqyUiGEE=
2+
github.com/Mrs4s/MiraiGo v0.0.0-20220318145114-35f774b86afa h1:UgOs+GImN0IYAZ/P/OH9nCOkEbidauK40F5axm11TcM=
3+
github.com/Mrs4s/MiraiGo v0.0.0-20220318145114-35f774b86afa/go.mod h1:kkUjOuOj2FMfqEEtnan/mxxKBZopYRBVIR4gSAdt7Hs=
4+
github.com/RomiChan/protobuf v0.0.0-20220318113238-d8a99598f896 h1:UFAqSbH6VqW5mEzQV2HVB7+p3k9JfTbidWJ/9F15yz0=
5+
github.com/RomiChan/protobuf v0.0.0-20220318113238-d8a99598f896/go.mod h1:CKKOWC7mBxd36zxsCB1V8DTrwlTNRQvkSVbYqyUiGEE=
106
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
117
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
128
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -47,8 +43,6 @@ github.com/json-iterator/go v1.1.11 h1:uVUAXhF2To8cbw/3xN3pxj6kk7TYKs98NIrTqPlMW
4743
github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
4844
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
4945
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
50-
github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc=
51-
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
5246
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
5347
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
5448
github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w=
@@ -91,7 +85,6 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV
9185
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
9286
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
9387
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
94-
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
9588
github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816 h1:J6v8awz+me+xeb/cUTotKgceAYouhIB3pjzgRd6IlGk=
9689
github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816/go.mod h1:tzym/CEb5jnFI+Q0k4Qq3+LvRF4gO3E2pxS8fHP8jcA=
9790
github.com/tidwall/gjson v1.11.0 h1:C16pk7tQNiH6VlCrtIXL1w8GaOsi1X3W8KDkE1BuYd4=
@@ -101,7 +94,6 @@ github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JT
10194
github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
10295
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
10396
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
104-
github.com/ugorji/go v1.2.6 h1:tGiWC9HENWE2tqYycIqFTNorMmFRVhNwCpDOpWqnk8E=
10597
github.com/ugorji/go v1.2.6/go.mod h1:anCg0y61KIhDlPZmnH+so+RQbysYVyDko0IMgJv0Nn0=
10698
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
10799
github.com/ugorji/go/codec v1.2.6 h1:7kbGefxLoDBuYXOms4yD7223OpNMMPNPZxXk5TvFcyQ=

pkg/bot/bot.go

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package bot
22

33
import (
4-
"runtime/debug"
54
"time"
65

76
"github.com/Mrs4s/MiraiGo/client"
@@ -15,18 +14,26 @@ var (
1514
LoginTokens TokenMap
1615
)
1716

17+
type Logger struct {
18+
}
19+
20+
func (l *Logger) Info(format string, args ...any) {
21+
log.Infof(format, args)
22+
}
23+
func (l *Logger) Warning(format string, args ...any) {
24+
log.Warnf(format, args)
25+
}
26+
func (l *Logger) Error(format string, args ...any) {
27+
log.Errorf(format, args)
28+
}
29+
func (l *Logger) Debug(format string, args ...any) {
30+
log.Debugf(format, args)
31+
}
32+
func (l *Logger) Dump(dumped []byte, format string, args ...any) {
33+
}
34+
1835
func InitLog(cli *client.QQClient) {
19-
cli.OnLog(func(c *client.QQClient, e *client.LogEvent) {
20-
switch e.Type {
21-
case "INFO":
22-
log.Info("MiraiGo -> " + e.Message)
23-
case "ERROR":
24-
log.Error("MiraiGo -> " + e.Message)
25-
log.Debugf("%+v", string(debug.Stack()))
26-
case "DEBUG":
27-
log.Debug("MiraiGo -> " + e.Message)
28-
}
29-
})
36+
cli.SetLogger(&Logger{})
3037

3138
cli.OnServerUpdated(func(bot *client.QQClient, e *client.ServerUpdatedEvent) bool {
3239
log.Infof("收到服务器地址更新通知, 将在下一次重连时应用. ")
@@ -50,7 +57,7 @@ func Login(cli *client.QQClient) (bool, error) {
5057

5158
func SetRelogin(cli *client.QQClient, retryInterval int, retryCount int) {
5259
LoginTokens.Store(cli.Uin, cli.GenToken())
53-
cli.OnDisconnected(func(bot *client.QQClient, e *client.ClientDisconnectedEvent) {
60+
cli.DisconnectedEvent.Subscribe(func(bot *client.QQClient, e *client.ClientDisconnectedEvent) {
5461
if bot.Online.Load() {
5562
return
5663
}

pkg/plugin/plugin.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,22 +48,22 @@ var GroupMutePluginList = make([]GroupMutePlugin, 0)
4848
var MemberPermissionChangedPluginList = make([]MemberPermissionChangedPlugin, 0)
4949

5050
func Serve(cli *client.QQClient) {
51-
cli.OnPrivateMessage(handlePrivateMessage)
52-
cli.OnGroupMessage(handleGroupMessage)
53-
cli.OnTempMessage(handleTempMessage)
54-
cli.OnGroupMemberJoined(handleMemberJoinGroup)
55-
cli.OnGroupMemberLeaved(handleMemberLeaveGroup)
56-
cli.OnJoinGroup(handleJoinGroup)
57-
cli.OnLeaveGroup(handleLeaveGroup)
58-
cli.OnNewFriendRequest(handleNewFriendRequest)
59-
cli.OnUserWantJoinGroup(handleUserJoinGroupRequest)
60-
cli.OnGroupInvited(handleGroupInvitedRequest)
61-
cli.OnGroupMessageRecalled(handleGroupMessageRecalled)
62-
cli.OnFriendMessageRecalled(handleFriendMessageRecalled)
63-
cli.OnNewFriendAdded(handleNewFriendAdded)
64-
cli.OnReceivedOfflineFile(handleOfflineFile)
65-
cli.OnGroupMuted(handleGroupMute)
66-
cli.OnGroupMemberPermissionChanged(handleMemberPermissionChanged)
51+
cli.PrivateMessageEvent.Subscribe(handlePrivateMessage)
52+
cli.GroupMessageEvent.Subscribe(handleGroupMessage)
53+
cli.TempMessageEvent.Subscribe(handleTempMessage)
54+
cli.GroupMemberJoinEvent.Subscribe(handleMemberJoinGroup)
55+
cli.GroupMemberLeaveEvent.Subscribe(handleMemberLeaveGroup)
56+
cli.GroupJoinEvent.Subscribe(handleJoinGroup)
57+
cli.GroupLeaveEvent.Subscribe(handleLeaveGroup)
58+
cli.NewFriendRequestEvent.Subscribe(handleNewFriendRequest)
59+
cli.UserWantJoinGroupEvent.Subscribe(handleUserJoinGroupRequest)
60+
cli.GroupInvitedEvent.Subscribe(handleGroupInvitedRequest)
61+
cli.GroupMessageRecalledEvent.Subscribe(handleGroupMessageRecalled)
62+
cli.FriendMessageRecalledEvent.Subscribe(handleFriendMessageRecalled)
63+
cli.NewFriendEvent.Subscribe(handleNewFriendAdded)
64+
cli.OfflineFileEvent.Subscribe(handleOfflineFile)
65+
cli.GroupMuteEvent.Subscribe(handleGroupMute)
66+
cli.GroupMemberPermissionChangedEvent.Subscribe(handleMemberPermissionChanged)
6767
}
6868

6969
// 添加私聊消息插件

0 commit comments

Comments
 (0)