diff --git a/internal/bard/request.go b/internal/bard/request.go index 7903170..84601f6 100644 --- a/internal/bard/request.go +++ b/internal/bard/request.go @@ -3,7 +3,7 @@ package bard import "time" type BardCache struct { - Bards map[string]Bard + Bards map[string]*Bard } func GarbageCollectCache(cache *BardCache) { @@ -18,7 +18,7 @@ var cache *BardCache func init() { cache = &BardCache{ - Bards: make(map[string]Bard), + Bards: make(map[string]*Bard), } go func() { for { diff --git a/internal/bard/utilities.go b/internal/bard/utilities.go new file mode 100644 index 0000000..669926a --- /dev/null +++ b/internal/bard/utilities.go @@ -0,0 +1,14 @@ +package bard + +import ( + "crypto/md5" + "encoding/hex" +) + +func HashConversation(conversation []string) string { + hash := md5.New() + for _, message := range conversation { + hash.Write([]byte(message)) + } + return hex.EncodeToString(hash.Sum(nil)) +}