Fixed for data storage and support for messages with nil username.
This commit is contained in:
parent
06a952bdca
commit
1fd64db523
|
@ -12,7 +12,7 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
messageRegexString = `{:message-id "(?P<ID>.+)",\s+:group-id "(?P<GroupID>.+)",\s+:content "(?P<Content>.+)",\s+:username "(?P<Username>.+)",\s+:type :public-group-message.+:timestamp (?P<Timestamp>\d+)}`
|
||||
messageRegexString = `{:message-id "(?P<ID>.+)",\s+:group-id "(?P<GroupID>.+)",\s+:content "(?P<Content>.+)",\s+:username ["]?(?P<Username>.+)["]?,\s+:type :public-group-message.+:timestamp (?P<Timestamp>\d+)}`
|
||||
)
|
||||
|
||||
var messageRegex *regexp.Regexp = regexp.MustCompile(messageRegexString)
|
||||
|
|
|
@ -69,7 +69,9 @@ func (ms *messagesStore) Add(message bots.StatusMessage) error {
|
|||
}
|
||||
|
||||
func (ms *messagesStore) Messages(channel string) []bots.StatusMessage {
|
||||
return messagesFromIterator(ms.db.NewIterator(util.BytesPrefix([]byte(channel)), nil))
|
||||
messages := messagesFromIterator(ms.db.NewIterator(util.BytesPrefix([]byte(channel)), nil))
|
||||
sort.Sort(ByTimestamp(messages))
|
||||
return messages
|
||||
}
|
||||
|
||||
func (ms *messagesStore) Close() {
|
||||
|
|
Loading…
Reference in New Issue