Last active
December 30, 2022 11:48
-
-
Save kkdai/f67d3ece464876bfb4c5fcf09a1ad1ca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
case *linebot.TextMessage: | |
// 預設訊息 | |
reply := "msg ID:" + message.ID + ":" + "Get:" + message.Text + " , \n OK!" | |
// 如果聊天機器人在群組中,開始儲存訊息。 | |
if event.Source.GroupID != "" { | |
// 先取得使用者 Display Name (也就是顯示的名稱) | |
userName := event.Source.UserID | |
userProfile, err := bot.GetProfile(event.Source.UserID).Do() | |
if err == nil { | |
userName = userProfile.DisplayName | |
} | |
// event.Source.GroupID 就是聊天群組的 ID,並且透過聊天群組的 ID 來放入 Map 之中。 | |
q := summaryQueue[event.Source.GroupID] | |
m := MsgDetail{ | |
MsgText: message.Text, | |
UserName: userName, | |
Time: time.Now(), | |
} | |
log.Println("Save msg:", m) | |
summaryQueue[event.Source.GroupID] = append(q, m) | |
log.Println("All msg:", q) | |
} | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment