mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-05-05 03:23:49 +08:00
fix atall permission error.
This commit is contained in:
parent
977ee0c859
commit
fff33e304c
@ -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()
|
||||
}
|
||||
|
@ -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)
|
||||
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user