mirror of
https://github.com/IllusionMan1212/gorc.git
synced 2026-10-24 02:12:33 +00:00
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:
+11
-1
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user