common

package
v0.0.0-...-14814ea Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 7, 2021 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
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
)

const ...

Variables

View Source
var (
	MessageTimeLayout       = "[2006-01-02 15:04:05 MST] "
	MessageTimeLayoutLength = len(MessageTimeLayout)
	MessageDateLayout       = "2006-01-02"
)

Log timestamp format

Functions

func CompressFile

func CompressFile(path string) (*os.File, error)

CompressFile compress an existing file

func ExtractChannelFromPath

func ExtractChannelFromPath(p string) (string, error)

ExtractChannelFromPath ...

func ReadCompressedFile

func ReadCompressedFile(path string) ([]byte, error)

ReadCompressedFile read compressed file

func ReadNickList

func ReadNickList(n NickStore, path string) error

ReadNickList adds nicks from the disk

func UncompressFile

func UncompressFile(path string) (*os.File, error)

UncompressFile uncompress an existing file

func WriteCompressedFile

func WriteCompressedFile(path string, data []byte) (*os.File, error)

WriteCompressedFile write compressed file

Types

type AvroBuffer

type AvroBuffer struct {
	WriterConstructor WriterConstructor
	Codec             container.Codec
	RecordsPerBlock   int64
	BytesPerFile      int
	Writer            io.Writer
	// contains filtered or unexported fields
}

AvroBuffer ...

func NewAvroBuffer

func NewAvroBuffer(writerConstructor WriterConstructor, writer io.Writer, codec container.Codec, recordsPerBlock int64, bytesPerFile int) (*AvroBuffer, error)

NewAvroBuffer ...

func (*AvroBuffer) Flush

func (a *AvroBuffer) Flush() error

Flush ...

func (*AvroBuffer) WriteRecord

func (a *AvroBuffer) WriteRecord(record container.AvroRecord) error

WriteRecord ...

type BigQueryWriter

type BigQueryWriter struct {
	// contains filtered or unexported fields
}

BigQueryWriter ...

func NewBigQueryWriter

func NewBigQueryWriter(config BigQueryWriterConfig) (*BigQueryWriter, error)

NewBigQueryWriter ...

func (*BigQueryWriter) Write

func (w *BigQueryWriter) Write(b []byte) (int, error)

Write ...

type BigQueryWriterConfig

type BigQueryWriterConfig struct {
	ProjectID          string `json:"projectID"`
	DatasetID          string `json:"datasetID"`
	TableID            string `json:"tableID"`
	ServiceAccountJSON string `json:"serviceAccountJSON"`
}

BigQueryWriterConfig ...

type Config

type Config struct {
	DestinyGG struct {
		LogHost   string `toml:"logHost"`
		SocketURL string `toml:"socketURL"`
		OriginURL string `toml:"originURL"`
		Cookie    string `toml:"cookie"`
	} `toml:"destinyGG"`
	Twitch struct {
		LogHost        string   `toml:"logHost"`
		SocketURL      string   `toml:"socketURL"`
		OriginURL      string   `toml:"originURL"`
		ClientID       string   `toml:"clientID"`
		OAuth          string   `toml:"oAuth"`
		Nick           string   `toml:"nick"`
		Admins         []string `toml:"admins"`
		CommandChannel string   `toml:"commandChannel"`
	} `toml:"twitch"`
	Bot struct {
		Admins []string `toml:"admins"`
	} `toml:"bot"`
	LogHost     string `toml:"logHost"`
	MaxOpenLogs int    `toml:"maxOpenLogs"`
}

Config settings

func GetConfig

func GetConfig() *Config

GetConfig returns config

func SetupConfig

func SetupConfig(path string) *Config

SetupConfig loads config data from json

type Destiny

type Destiny struct {
	// contains filtered or unexported fields
}

Destiny destiny.gg chat client

func NewDestiny

func NewDestiny() *Destiny

NewDestiny new destiny.gg chat client

func (*Destiny) Message

func (c *Destiny) Message(payload string) error

Message send message

func (*Destiny) Messages

func (c *Destiny) Messages() <-chan *Message

Messages channel accessor

func (*Destiny) Run

func (c *Destiny) Run()

Run connect and start message read loop

func (*Destiny) Stop

func (c *Destiny) Stop()

Stop ...

func (*Destiny) Whisper

func (c *Destiny) Whisper(nick, data string) error

Whisper send private message

type Message

type Message struct {
	Type    string
	Channel string
	Nick    string
	Data    string
	Time    time.Time
}

Message data

func ParseMessageLine

func ParseMessageLine(b string) (*Message, error)

ParseMessageLine parse log line into message struct

func (*Message) NickPath

func (m *Message) NickPath() string

NickPath return sanitized nick for use with fs

func (*Message) String

func (m *Message) String() string

type NickCaseMap

type NickCaseMap map[string]string

NickCaseMap map from lower case nicks

func (NickCaseMap) Add

func (n NickCaseMap) Add(nick string)

Add implement NickStore

func (NickCaseMap) Remove

func (n NickCaseMap) Remove(nick string)

Remove deletes a nick from the list

type NickList

type NickList map[string]struct{}

NickList list of unique nicks

func (NickList) Add

func (n NickList) Add(nick string)

Add append nick to list

func (NickList) Remove

func (n NickList) Remove(nick string)

Remove deletes a nick from the list

func (NickList) WriteTo

func (n NickList) WriteTo(path string) error

WriteTo writes nicks to the disk

type NickListLower

type NickListLower map[string]struct{}

NickListLower lower case nick list for case insensitive search

func (NickListLower) Add

func (n NickListLower) Add(nick string)

Add implement NickStore

func (NickListLower) Remove

func (n NickListLower) Remove(nick string)

Remove deletes a nick from the list

type NickSearch

type NickSearch struct {
	// contains filtered or unexported fields
}

NickSearch scans nick indexes in reverse chronological order

func NewNickSearch

func NewNickSearch(path string, nick string) (*NickSearch, error)

NewNickSearch create scanner

func (*NickSearch) Month

func (n *NickSearch) Month(m string) (string, error)

Month searches for a nick in m

func (*NickSearch) Next

func (n *NickSearch) Next() (*NickSearchResult, error)

Next find next occurrence

type NickSearchResult

type NickSearchResult struct {
	// contains filtered or unexported fields
}

NickSearchResult nick/path data

func (*NickSearchResult) Date

func (n *NickSearchResult) Date() time.Time

Date time object

func (*NickSearchResult) Day

func (n *NickSearchResult) Day() string

Day path string

func (*NickSearchResult) Month

func (n *NickSearchResult) Month() string

Month path string

func (*NickSearchResult) Nick

func (n *NickSearchResult) Nick() string

Nick case corrected nick

type NickStore

type NickStore interface {
	Add(string)
	Remove(string)
}

NickStore nick list data

type Twitch

type Twitch struct {
	ChLock sync.RWMutex

	MessagePattern *regexp.Regexp
	SubPattern     *regexp.Regexp
	// contains filtered or unexported fields
}

Twitch twitch chat client

func NewTwitch

func NewTwitch() *Twitch

NewTwitch new twitch chat client

func (*Twitch) Channels

func (c *Twitch) Channels() []string

Channels ...

func (*Twitch) Join

func (c *Twitch) Join(ch string) error

Join channel

func (*Twitch) Leave

func (c *Twitch) Leave(ch string) error

Leave channel

func (*Twitch) Message

func (c *Twitch) Message(ch, payload string) error

Message send a message to a channel

func (*Twitch) Messages

func (c *Twitch) Messages() <-chan *Message

Messages channel accessor

func (*Twitch) Run

func (c *Twitch) Run()

Run connect and start message read loop

func (*Twitch) Stop

func (c *Twitch) Stop(wg *sync.WaitGroup)

Stop stops the chats

type WriterConstructor

type WriterConstructor func(writer io.Writer, codec container.Codec, recordsPerBlock int64) (*container.Writer, error)

WriterConstructor ...

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL