-
-
Notifications
You must be signed in to change notification settings - Fork 69
/
marker.go
61 lines (49 loc) · 1.39 KB
/
marker.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package msg_marker
import (
"github.com/Mrs4s/MiraiGo/client"
"github.com/Mrs4s/MiraiGo/message"
"github.com/Sora233/MiraiGo-Template/bot"
"github.com/Sora233/MiraiGo-Template/config"
"github.com/Sora233/MiraiGo-Template/utils"
"sync"
)
func init() {
instance = new(marker)
bot.RegisterModule(instance)
}
const moduleId = "sora233.message-read-marker"
type marker struct{}
var instance *marker
var logger = utils.GetModuleLogger(moduleId)
func (m *marker) MiraiGoModule() bot.ModuleInfo {
return bot.ModuleInfo{
ID: moduleId,
Instance: instance,
}
}
func (m *marker) Init() {
}
func (m *marker) PostInit() {
}
func (m *marker) Serve(bot *bot.Bot) {
if config.GlobalConfig.GetBool("message-marker.disable") {
logger.Debug("自动已读被禁用")
return
}
logger.Debug("自动已读已开启")
bot.GroupMessageEvent.Subscribe(func(client *client.QQClient, message *message.GroupMessage) {
if message.Sender.Uin != client.Uin {
client.MarkGroupMessageReaded(message.GroupCode, int64(message.Id))
}
})
bot.PrivateMessageEvent.Subscribe(func(qqClient *client.QQClient, privateMessage *message.PrivateMessage) {
if privateMessage.Sender.Uin != qqClient.Uin {
qqClient.MarkPrivateMessageReaded(privateMessage.Sender.Uin, int64(privateMessage.Time))
}
})
}
func (m *marker) Start(bot *bot.Bot) {
}
func (m *marker) Stop(bot *bot.Bot, wg *sync.WaitGroup) {
wg.Done()
}