Skip to content

Commit

Permalink
fix atall permission error.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrs4s committed Feb 20, 2021
1 parent 977ee0c commit fff33e3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion coolq/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,15 @@ func (bot *CQBot) CQGetWordSlices(content string) MSG {
// https://git.io/Jtz1c
func (bot *CQBot) CQSendGroupMessage(groupID int64, i interface{}, autoEscape bool) MSG {
var str string
group := bot.Client.FindGroup(groupID)
if group == nil {
return Failed(100, "GROUP_NOT_FOUND", "群聊不存在")
}
fixAt := func(elem []message.IMessageElement) {
for _, e := range elem {
if at, ok := e.(*message.AtElement); ok && at.Target != 0 {
at.Display = "@" + func() string {
mem := bot.Client.FindGroup(groupID).FindMember(at.Target)
mem := group.FindMember(at.Target)
if mem != nil {
return mem.DisplayName()
}
Expand Down
5 changes: 5 additions & 0 deletions coolq/bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ func (bot *CQBot) UploadLocalImageAsPrivate(userID int64, img *LocalImageElement
// SendGroupMessage 发送群消息
func (bot *CQBot) SendGroupMessage(groupID int64, m *message.SendingMessage) int32 {
var newElem []message.IMessageElement
group := bot.Client.FindGroup(groupID)
for _, elem := range m.Elements {
if i, ok := elem.(*LocalImageElement); ok {
gm, err := bot.UploadLocalImageAsGroup(groupID, i)
Expand Down Expand Up @@ -218,6 +219,10 @@ func (bot *CQBot) SendGroupMessage(groupID int64, m *message.SendingMessage) int
}
return bot.InsertGroupMessage(ret)
}
if i, ok := elem.(*message.AtElement); ok && i.Target == 0 && group.SelfPermission() == client.Member {
newElem = append(newElem, message.NewText("@全体成员"))
continue
}
newElem = append(newElem, elem)
}
if len(newElem) == 0 {
Expand Down

0 comments on commit fff33e3

Please sign in to comment.