forked from MemeLabs/overrustlelogs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon.go
38 lines (32 loc) · 788 Bytes
/
common.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package common
import (
"fmt"
"regexp"
"time"
)
// const ...
const (
HandshakeTimeout = 10 * time.Second
MaxChannelsPerChat = 50
MessageBufferSize = 1000
SocketReadTimeout = 6 * time.Minute
SocketReconnectDelay = 20 * time.Second
SocketWriteDebounce = 500 * time.Millisecond
SocketWriteTimeout = 5 * time.Second
)
var messageNickPathUnsafe = regexp.MustCompile("[^a-zA-Z0-9_-]")
// Message data
type Message struct {
Type string
Channel string
Nick string
Data string
Time time.Time
}
func (m *Message) String() string {
return fmt.Sprintf("#%s : < %s > : %s", m.Channel, m.Nick, m.Data)
}
// NickPath return sanitized nick for use with fs
func (m *Message) NickPath() string {
return messageNickPathUnsafe.ReplaceAllString(m.Nick, "")
}