mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-05-05 03:23:49 +08:00
clean send msg arg.
This commit is contained in:
parent
89eaf91371
commit
e5a8a406a4
34
coolq/api.go
34
coolq/api.go
@ -351,8 +351,7 @@ func (bot *CQBot) CQGetWordSlices(content string) MSG {
|
||||
// CQSendGroupMessage 发送群消息
|
||||
//
|
||||
// https://git.io/Jtz1c
|
||||
func (bot *CQBot) CQSendGroupMessage(groupID int64, i interface{}, autoEscape bool) MSG {
|
||||
var str string
|
||||
func (bot *CQBot) CQSendGroupMessage(groupID int64, m gjson.Result, autoEscape bool) MSG {
|
||||
group := bot.Client.FindGroup(groupID)
|
||||
if group == nil {
|
||||
return Failed(100, "GROUP_NOT_FOUND", "群聊不存在")
|
||||
@ -363,12 +362,13 @@ func (bot *CQBot) CQSendGroupMessage(groupID int64, i interface{}, autoEscape bo
|
||||
mem := group.FindMember(at.Target)
|
||||
if mem != nil {
|
||||
at.Display = "@" + mem.DisplayName()
|
||||
}
|
||||
} else {
|
||||
at.Display = "@" + strconv.FormatInt(at.Target, 10)
|
||||
}
|
||||
}
|
||||
}
|
||||
if m, ok := i.(gjson.Result); ok {
|
||||
}
|
||||
|
||||
if m.Type == gjson.JSON {
|
||||
elem := bot.ConvertObjectMessage(m, true)
|
||||
fixAt(elem)
|
||||
@ -379,17 +379,9 @@ func (bot *CQBot) CQSendGroupMessage(groupID int64, i interface{}, autoEscape bo
|
||||
log.Infof("发送群 %v(%v) 的消息: %v (%v)", group.Name, groupID, limitedString(ToStringMessage(elem, groupID)), mid)
|
||||
return OK(MSG{"message_id": mid})
|
||||
}
|
||||
str = func() string {
|
||||
if m.Str != "" {
|
||||
return m.Str
|
||||
}
|
||||
return m.Raw
|
||||
}()
|
||||
} else if s, ok := i.(string); ok {
|
||||
str = s
|
||||
}
|
||||
str := m.String()
|
||||
if str == "" {
|
||||
log.Warnf("群消息发送失败: 信息为空. MSG: %v", i)
|
||||
log.Warn("群消息发送失败: 信息为空.")
|
||||
return Failed(100, "EMPTY_MSG_ERROR", "消息为空")
|
||||
}
|
||||
var elem []message.IMessageElement
|
||||
@ -532,9 +524,7 @@ func (bot *CQBot) CQSendGroupForwardMessage(groupID int64, m gjson.Result) MSG {
|
||||
// CQSendPrivateMessage 发送私聊消息
|
||||
//
|
||||
// https://git.io/Jtz1l
|
||||
func (bot *CQBot) CQSendPrivateMessage(userID int64, groupID int64, i interface{}, autoEscape bool) MSG {
|
||||
var str string
|
||||
if m, ok := i.(gjson.Result); ok {
|
||||
func (bot *CQBot) CQSendPrivateMessage(userID int64, groupID int64, m gjson.Result, autoEscape bool) MSG {
|
||||
if m.Type == gjson.JSON {
|
||||
elem := bot.ConvertObjectMessage(m, false)
|
||||
mid := bot.SendPrivateMessage(userID, groupID, &message.SendingMessage{Elements: elem})
|
||||
@ -544,15 +534,7 @@ func (bot *CQBot) CQSendPrivateMessage(userID int64, groupID int64, i interface{
|
||||
log.Infof("发送好友 %v(%v) 的消息: %v (%v)", userID, userID, limitedString(m.String()), mid)
|
||||
return OK(MSG{"message_id": mid})
|
||||
}
|
||||
str = func() string {
|
||||
if m.Str != "" {
|
||||
return m.Str
|
||||
}
|
||||
return m.Raw
|
||||
}()
|
||||
} else if s, ok := i.(string); ok {
|
||||
str = s
|
||||
}
|
||||
str := m.String()
|
||||
if str == "" {
|
||||
return Failed(100, "EMPTY_MSG_ERROR", "消息为空")
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ func RunLambdaClient(bot *coolq.CQBot, conf *config.LambdaServer) {
|
||||
req := cli.next()
|
||||
if req == nil {
|
||||
writer := lambdaResponseWriter{statusCode: 200}
|
||||
writer.Write(nil)
|
||||
_, _ = writer.Write(nil)
|
||||
continue
|
||||
}
|
||||
func() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user