Created
January 16, 2023 10:18
-
-
Save kkdai/62dc8354e7ce3e7607aeda0513513a58 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // 如果有預設 DABTASE_URL 就建立 PostGresSQL; 反之則建立 Mem DB | |
| pSQL := os.Getenv("DATABASE_URL") | |
| if pSQL != "" { | |
| summaryQueue = NewPGSql(pSQL) | |
| } else { | |
| summaryQueue = NewMemDB() | |
| } | |
| //.... | |
| func handleSumAll(event *linebot.Event, message string) { | |
| // 把聊天群組裡面的訊息都捲出來(依照先後順序) | |
| oriContext := "" | |
| q := summaryQueue.ReadGroupInfo(getGroupID(event)) | |
| 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")) | |
| } | |
| ... | |
| } | |
| func handleListAll(event *linebot.Event, message string) { | |
| reply := "" | |
| q := summaryQueue.ReadGroupInfo(getGroupID(event)) | |
| for _, m := range q { | |
| reply = reply + fmt.Sprintf("[%s]: %s . %s\n", m.UserName, m.MsgText, m.Time.Local().UTC().Format("2006-01-02 15:04:05")) | |
| } | |
| if _, err := bot.ReplyMessage(event.ReplyToken, 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