Created
January 13, 2023 14:21
-
-
Save kkdai/2b84fb24fef3e3313cd6b963dcd26a14 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
// 如果有預設 DABTASE_URL 就建立 PostGresSQL; 反之則建立 Mem DB | |
pSQL := os.Getenv("DATABASE_URL") | |
if pSQL != "" { | |
summaryQueue = NewPGSql(pSQL) | |
} else { | |
summaryQueue = NewMemDB() | |
} | |
// DB Access | |
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")) | |
} | |
... | |
// DB append | |
// event.Source.GroupID 就是聊天群組的 ID,並且透過聊天群組的 ID 來放入 Map 之中。 | |
m := MsgDetail{ | |
MsgText: message, | |
UserName: userName, | |
Time: time.Now(), | |
} | |
summaryQueue.AppendGroupInfo(getGroupID(event), m) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment