Skip to content

Commit

Permalink
修改日志
Browse files Browse the repository at this point in the history
  • Loading branch information
lianhong2758 committed Oct 26, 2024
1 parent 54dcad1 commit 67ba05f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 8 deletions.
31 changes: 28 additions & 3 deletions server/qq/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (c *Config) BotSend(ctx *rosm.Ctx, msg ...message.MessageSegment) rosm.H {
case "DIRECT_MESSAGE_CREATE":
url = fmt.Sprintf(urlSendGuildPrivate, ctx.Being.RoomID2) //频道私聊
}
log.Infoln("[send]["+url+"]", tool.BytesToString(data))
log.Infoln("[]["+url+"]", tool.BytesToString(data))
data, err := web.Web(clientConst, host+url, http.MethodPost, makeHeard(c.access, c.BotToken.AppId), bytes.NewReader(data))
if err != nil {
log.Errorln("[send][", host+url, "]", err)
Expand All @@ -70,9 +70,34 @@ func (c *Config) BotSend(ctx *rosm.Ctx, msg ...message.MessageSegment) rosm.H {
return "0"
}(err != nil)}
}
//未来实现

func (c *Config) BotSendCustom(ctx *rosm.Ctx, count any) rosm.H {
return rosm.H{}
url := ""
//判断私聊
switch ctx.Being.Def["type"].(string) {
case "GROUP_AT_MESSAGE_CREATE":
url = fmt.Sprintf(urlSendGroup, ctx.Being.RoomID) //群聊
case "C2C_MESSAGE_CREATE":
url = fmt.Sprintf(urlSendPrivate, ctx.Being.User.ID) //私聊
case "AT_MESSAGE_CREATE", "MESSAGE_CREATE":
url = fmt.Sprintf(urlSendGuild, ctx.Being.RoomID) //频道
case "DIRECT_MESSAGE_CREATE":
url = fmt.Sprintf(urlSendGuildPrivate, ctx.Being.RoomID2) //频道私聊
}
log.Infoln("[qq] [↑]["+url+"]",count.(string))
data, err := web.Web(clientConst, host+url, http.MethodPost, makeHeard(c.access, c.BotToken.AppId), bytes.NewReader(tool.StringToBytes(count.(string))))
if err != nil {
log.Errorln("[send][", host+url, "]", err)
}
log.Debugln("[send-result]", tool.BytesToString(data))
sendState := new(qqmsg.SendState)
_ = json.Unmarshal(data, sendState)
return rosm.H{"id": sendState.MsgID, "code": func(b bool) string {
if b {
return "1"
}
return "0"
}(err != nil)}
}

func (c *Config) GetPortraitURI(ctx *rosm.Ctx) string {
Expand Down
10 changes: 5 additions & 5 deletions server/qq/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ func (c *Config) process(playload *WebsocketPayload) {
raw := new(RawPrivateMessage)
err := json.Unmarshal(playload.D, raw)
if err != nil {
log.Errorln("[info]", err)
log.Errorln("[qq-err]", err)
return
}
log.Infof("[info]接收私聊消息%s:%s", raw.Author.UserOpenid, raw.Content)
log.Infof("[qq] [↓]私聊消息%s:%s", raw.Author.UserOpenid, raw.Content)
ctx := &rosm.Ctx{
Bot: c,
BotType: "qq_group",
Expand All @@ -43,10 +43,10 @@ func (c *Config) process(playload *WebsocketPayload) {
raw := new(RawGroupMessage)
err := json.Unmarshal(playload.D, raw)
if err != nil {
log.Errorln("[info]", err)
log.Errorln("[qq-err]", err)
return
}
log.Infof("[info]接收消息[%s]%s:%s", raw.GroupID, raw.Author.ID, raw.Content)
log.Infof("[qq] [↓]群聊消息[%s]%s:%s", raw.GroupID, raw.Author.ID, raw.Content)
ctx := &rosm.Ctx{
Bot: c,
BotType: "qq_group",
Expand Down Expand Up @@ -77,7 +77,7 @@ func (c *Config) process(playload *WebsocketPayload) {
log.Errorln("[info]", err)
return
}
log.Infof("[info]接收消息[%s]%s:%s", raw.GuildID, raw.Author.Username, raw.Content)
log.Infof("[qq] [↓]频道消息[%s]%s:%s", raw.GuildID, raw.Author.Username, raw.Content)
at := []string{}
for _, v := range raw.Mentions {
at = append(at, v.ID)
Expand Down

0 comments on commit 67ba05f

Please sign in to comment.