为Message添加string方法

This commit is contained in:
eatmoreapple 2021-09-25 20:33:38 +08:00
parent c2641bd6ad
commit 5cd4e2bb7e
2 changed files with 5 additions and 0 deletions

View File

@ -39,6 +39,7 @@ func TestLogout(t *testing.T) {
func TestMessageHandle(t *testing.T) {
bot := DefaultBot(Desktop)
bot.MessageHandler = func(msg *Message) {
fmt.Println(msg)
if msg.IsText() && msg.Content == "ping" {
msg.ReplyText("pong")
}

View File

@ -647,3 +647,7 @@ func (a AppMessageData) IsFile() bool {
func (m *Message) IsComeFromGroup() bool {
return m.IsSendByGroup() || strings.HasPrefix(m.ToUserName, "@@")
}
func (m *Message) String() string {
return fmt.Sprintf("<%s:ID:%s>", m.MsgType, m.MsgId)
}