twitchlogger

package module
v0.0.0-...-594c11d Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2023 License: MIT Imports: 5 Imported by: 0

README

twitchlogger

Lightweight and minimal Twitch chat logger. It is able to log every live chat on twitch (at once) with very low CPU and memory usage.

Commands

There are 2 commands, twitch-log and twitch-channels:

  • twitch-channels is for fetching all live channels from the Twitch API, it outputs CSV data (user_id,channel_name,viewers). Check the usage with twitch-channels -h
  • twitch-log is for logging the chats. The input must be a stream with every channel name separated by a newline. It outputs IRC messages.

You can connect twitch-channels and twitch-log by piping twitch-channels to awk, as in the examples below.

Installation

Download the executables from this repo's Releases page and put them in your $PATH

OR

go get -u github.com/mlvzk/twitchlogger/...

Examples

Pipe twitch-channels to awk to only get the channel's name and pipe it then to twitch-log:

twitch-channels \
| awk -F, '{ print $2 }' \
| twitch-log

Log only one channel:

twitch-log <<<"moonmoon_ow"

Fetch only english(locale id en) streams with no less than 50 viewers, and loop it to also fetch future streams:

twitch-channels -language en -min 50 -loop

Fetch, transform, log, filter to only PRIVMSG messages and beautify the output:

twitch-channels -language en -min 20 -loop \
| awk -F, '{ print $2 }' \
| twitch-log \
| awk 'match($0, /:(\w+)!.*PRIVMSG #(\w+) :(.*)/, m) { print strftime("%Y-%m-%d %H:%M:%S")" \033[34m"m[1]"\033[0m to \033[35m#"m[2]"\033[0m: "m[3] }' # only gnu version of awk, gawk

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TwitchChannel

type TwitchChannel struct {
	ID   int    `json:"_id"`
	Name string `json:"name"`
}

type TwitchStream

type TwitchStream struct {
	Viewers int           `json:"viewers"`
	Channel TwitchChannel `json:"channel"`
}

type TwitchStreamsPager

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

func NewTwitchStreamsPager

func NewTwitchStreamsPager(language, clientID string) *TwitchStreamsPager

NewTwitchStreamsPager returns the initial TwitchStreamsPager

func (*TwitchStreamsPager) Next

func (pager *TwitchStreamsPager) Next() ([]TwitchStream, bool, error)

Next returns the TwitchStreams for the current page and progresses. bool is true if it hits the end.

func (*TwitchStreamsPager) Reset

func (pager *TwitchStreamsPager) Reset()

Reset resets the pager to it's initial position

type TwitchStreamsResponse

type TwitchStreamsResponse struct {
	Total   int            `json:"_total"`
	Streams []TwitchStream `json:"streams"`
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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