Last active
December 30, 2022 11:46
-
-
Save kkdai/cc6a635c495bfefb6fcc35e8271e3216 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
... | |
// 把聊天群組裡面的訊息都捲出來(依照先後順序) | |
oriContext := "" | |
q := summaryQueue[event.Source.GroupID] | |
for _, m := range q { | |
// [xxx]: 他講了什麼... 時間 | |
oriContext = oriContext + fmt.Sprintf("[%s]: %s . %s\n", m.UserName, m.MsgText, m.Time.Local().UTC().Format("2006-01-02 15:04:05")) | |
} | |
// 取得使用者暱稱 | |
userName := event.Source.UserID | |
userProfile, err := bot.GetProfile(event.Source.UserID).Do() | |
if err == nil { | |
userName = userProfile.DisplayName | |
} | |
// 訊息內先回,再來總結。 | |
if _, err = bot.ReplyMessage(event.ReplyToken, linebot.NewTextMessage("好的,總結文字已經發給您了"+userName)).Do(); err != nil { | |
log.Print(err) | |
} | |
// 就是請 ChatGPT 幫你總結 | |
oriContext = fmt.Sprintf("幫我總結 `%s`", oriContext) | |
reply = CompleteContext(oriContext) | |
// 因為 ChatGPT 可能會很慢,所以這邊後來用 SendMsg 來發送私訊給使用者。 | |
if _, err = bot.PushMessage(event.Source.UserID, linebot.NewTextMessage(reply)).Do(); err != nil { | |
log.Print(err) | |
} | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment