1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-05-05 03:23:49 +08:00

feature private poke.

This commit is contained in:
Mrs4s 2020-11-14 19:03:36 +08:00
parent 2cbf23bceb
commit b8ec05e1c1
5 changed files with 29 additions and 7 deletions

View File

@ -56,6 +56,7 @@ func NewQQBot(cli *client.QQClient, conf *global.JsonConfig) *CQBot {
bot.Client.OnGroupMuted(bot.groupMutedEvent)
bot.Client.OnGroupMessageRecalled(bot.groupRecallEvent)
bot.Client.OnGroupNotify(bot.groupNotifyEvent)
bot.Client.OnFriendNotify(bot.friendNotifyEvent)
bot.Client.OnFriendMessageRecalled(bot.friendRecallEvent)
bot.Client.OnReceivedOfflineFile(bot.offlineFileEvent)
bot.Client.OnJoinGroup(bot.joinGroupEvent)
@ -235,6 +236,10 @@ func (bot *CQBot) SendPrivateMessage(target int64, m *message.SendingMessage) in
newElem = append(newElem, fm)
continue
}
if i, ok := elem.(*PokeElement); ok {
bot.Client.SendFriendPoke(i.Target)
return 0
}
if i, ok := elem.(*message.VoiceElement); ok {
fv, err := bot.Client.UploadPrivatePtt(target, i.Data)
if err != nil {

View File

@ -434,9 +434,6 @@ func (bot *CQBot) ToElement(t string, d map[string]string, group bool) (m interf
}
case "poke":
if !group {
return nil, errors.New("todo") // TODO: private poke
}
t, _ := strconv.ParseInt(d["qq"], 10, 64)
return &PokeElement{Target: t}, nil
case "gift":

View File

@ -220,7 +220,7 @@ func (bot *CQBot) groupRecallEvent(c *client.QQClient, e *client.GroupMessageRec
})
}
func (bot *CQBot) groupNotifyEvent(c *client.QQClient, e client.IGroupNotifyEvent) {
func (bot *CQBot) groupNotifyEvent(c *client.QQClient, e client.INotifyEvent) {
group := c.FindGroup(e.From())
switch notify := e.(type) {
case *client.GroupPokeNotifyEvent:
@ -279,6 +279,24 @@ func (bot *CQBot) groupNotifyEvent(c *client.QQClient, e client.IGroupNotifyEven
}
}
func (bot *CQBot) friendNotifyEvent(c *client.QQClient, e client.INotifyEvent) {
friend := c.FindFriend(e.From())
switch notify := e.(type) {
case *client.FriendPokeNotifyEvent:
log.Infof("好友 %v 戳了戳你.", friend.Nickname)
bot.dispatchEventMessage(MSG{
"post_type": "notice",
"notice_type": "notify",
"sub_type": "poke",
"self_id": c.Uin,
"user_id": notify.Sender,
"sender_id": notify.Sender,
"target_id": notify.Receiver,
"time": time.Now().Unix(),
})
}
}
func (bot *CQBot) friendRecallEvent(c *client.QQClient, e *client.FriendMessageRecalledEvent) {
f := c.FindFriend(e.FriendUin)
gid := ToGlobalId(e.FriendUin, e.MessageId)

2
go.mod
View File

@ -3,7 +3,7 @@ module github.com/Mrs4s/go-cqhttp
go 1.14
require (
github.com/Mrs4s/MiraiGo v0.0.0-20201114071121-b813765774d7
github.com/Mrs4s/MiraiGo v0.0.0-20201114105600-231b2d89dbb9
github.com/dustin/go-humanize v1.0.0
github.com/getlantern/go-update v0.0.0-20190510022740-79c495ab728c
github.com/getlantern/golog v0.0.0-20201105130739-9586b8bde3a9 // indirect

6
go.sum
View File

@ -1,7 +1,9 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Mrs4s/MiraiGo v0.0.0-20201114071121-b813765774d7 h1:/vnL6vhst5buzs7YwVxEZe6NuZDdayb/e7gEZ5n+YWg=
github.com/Mrs4s/MiraiGo v0.0.0-20201114071121-b813765774d7/go.mod h1:pAsWtMIwqkBXr5DkUpTIHoWQJNduVnX9WSBPmPvkuCs=
github.com/Mrs4s/MiraiGo v0.0.0-20201114105236-1ea9f982fee4 h1:0qoqKkSLTnWBS2rZm95ey9YYbCo4sujO4Kk2frw27yY=
github.com/Mrs4s/MiraiGo v0.0.0-20201114105236-1ea9f982fee4/go.mod h1:pAsWtMIwqkBXr5DkUpTIHoWQJNduVnX9WSBPmPvkuCs=
github.com/Mrs4s/MiraiGo v0.0.0-20201114105600-231b2d89dbb9 h1:evnR9D9rXcBTUzioFf7XlXX4KbZBhc0/Urp09yV01dc=
github.com/Mrs4s/MiraiGo v0.0.0-20201114105600-231b2d89dbb9/go.mod h1:pAsWtMIwqkBXr5DkUpTIHoWQJNduVnX9WSBPmPvkuCs=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=