Commit 1a3cba54 authored by Mrs4s's avatar Mrs4s

add sending log limit.

parent 9ecef962
...@@ -6,6 +6,7 @@ import ( ...@@ -6,6 +6,7 @@ import (
"path" "path"
"runtime" "runtime"
"strconv" "strconv"
"strings"
"time" "time"
"github.com/Mrs4s/MiraiGo/binary" "github.com/Mrs4s/MiraiGo/binary"
...@@ -125,7 +126,7 @@ func (bot *CQBot) CQSendGroupMessage(groupId int64, i interface{}, autoEscape bo ...@@ -125,7 +126,7 @@ func (bot *CQBot) CQSendGroupMessage(groupId int64, i interface{}, autoEscape bo
if mid == -1 { if mid == -1 {
return Failed(100) return Failed(100)
} }
log.Infof("发送群 %v(%v) 的消息: %v (%v)", groupId, groupId, m.String(), mid) log.Infof("发送群 %v(%v) 的消息: %v (%v)", groupId, groupId, limitedString(m.String()), mid)
return OK(MSG{"message_id": mid}) return OK(MSG{"message_id": mid})
} }
str = func() string { str = func() string {
...@@ -152,7 +153,7 @@ func (bot *CQBot) CQSendGroupMessage(groupId int64, i interface{}, autoEscape bo ...@@ -152,7 +153,7 @@ func (bot *CQBot) CQSendGroupMessage(groupId int64, i interface{}, autoEscape bo
if mid == -1 { if mid == -1 {
return Failed(100) return Failed(100)
} }
log.Infof("发送群 %v(%v) 的消息: %v (%v)", groupId, groupId, str, mid) log.Infof("发送群 %v(%v) 的消息: %v (%v)", groupId, groupId, limitedString(str), mid)
return OK(MSG{"message_id": mid}) return OK(MSG{"message_id": mid})
} }
...@@ -249,7 +250,7 @@ func (bot *CQBot) CQSendPrivateMessage(userId int64, i interface{}, autoEscape b ...@@ -249,7 +250,7 @@ func (bot *CQBot) CQSendPrivateMessage(userId int64, i interface{}, autoEscape b
if mid == -1 { if mid == -1 {
return Failed(100) return Failed(100)
} }
log.Infof("发送好友 %v(%v) 的消息: %v (%v)", userId, userId, m.String(), mid) log.Infof("发送好友 %v(%v) 的消息: %v (%v)", userId, userId, limitedString(m.String()), mid)
return OK(MSG{"message_id": mid}) return OK(MSG{"message_id": mid})
} }
str = func() string { str = func() string {
...@@ -274,7 +275,7 @@ func (bot *CQBot) CQSendPrivateMessage(userId int64, i interface{}, autoEscape b ...@@ -274,7 +275,7 @@ func (bot *CQBot) CQSendPrivateMessage(userId int64, i interface{}, autoEscape b
if mid == -1 { if mid == -1 {
return Failed(100) return Failed(100)
} }
log.Infof("发送好友 %v(%v) 的消息: %v (%v)", userId, userId, str, mid) log.Infof("发送好友 %v(%v) 的消息: %v (%v)", userId, userId, limitedString(str), mid)
return OK(MSG{"message_id": mid}) return OK(MSG{"message_id": mid})
} }
...@@ -758,3 +759,12 @@ func convertGroupMemberInfo(groupId int64, m *client.GroupMemberInfo) MSG { ...@@ -758,3 +759,12 @@ func convertGroupMemberInfo(groupId int64, m *client.GroupMemberInfo) MSG {
"card_changeable": false, "card_changeable": false,
} }
} }
func limitedString(str string) string {
if strings.Count(str, "") <= 10 {
return str
}
limited := []rune(str)
limited = limited[:10]
return string(limited) + " ..."
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment