feat: message timestamps

* made it easier to styles and prefix messages
* added timestamps to messages
* added prefix and styles to server messages
* append current date to host channel
* fixed some styles issues
This commit is contained in:
2022-02-19 16:24:39 +02:00
parent 6c538cc352
commit f4dd0066c8
11 changed files with 222 additions and 51 deletions
+11 -1
View File
@@ -17,12 +17,14 @@
package parser
import (
"fmt"
"regexp"
"strings"
"time"
)
type IRCMessage struct {
// TODO: prefix: that will hold the timestamp AND the server message prefix (==)
Timestamp string
Tags Tags // starts with @ | Optional
Source string // starts with : | Optional
Command string // can either be a string or a numeric value | Required
@@ -31,6 +33,12 @@ type IRCMessage struct {
type Tags map[string]string
func (m *IRCMessage) setTimestamp() {
// TODO: get timestamp from time tag
now := time.Now()
m.Timestamp = fmt.Sprintf("[%02d:%02d]", now.Hour(), now.Minute())
}
func parseTags(rawTags string) Tags {
tags := make(Tags, 0)
rawTagsSlice := strings.Split(rawTags, ";")
@@ -108,5 +116,7 @@ func ParseIRCMessage(line string) (IRCMessage, bool) {
ircMessage.Parameters = finalParams
}
ircMessage.setTimestamp()
return ircMessage, true
}