twitchirc

package
v0.0.0-develop Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrZeroLengthMessage is returned when parsing if the input is
	// zero-length.
	ErrZeroLengthMessage = errors.New("irc: cannot parse zero-length message")

	// ErrMissingDataAfterPrefix is returned when parsing if there is
	// no message data after the prefix.
	ErrMissingDataAfterPrefix = errors.New("irc: no message data after prefix")

	// ErrMissingDataAfterTags is returned when parsing if there is no
	// message data after the tags.
	ErrMissingDataAfterTags = errors.New("irc: no message data after tags")

	// ErrMissingCommand is returned when parsing if there is no
	// command in the parsed message.
	ErrMissingCommand = errors.New("irc: missing message command")

	ErrUnhandledCommand = errors.New("irc: message command not handled by parser")
)

Functions

This section is empty.

Types

type AccountProvider

type AccountProvider interface {
	GetAccountBy(id string) (save.Account, error)
	UpdateTokensFor(id, accessToken, refreshToken string) error
}

type AnnouncementColor

type AnnouncementColor string
const (
	Primary AnnouncementColor = "PRIMARY"
	Blue    AnnouncementColor = "BLUE"
	Green   AnnouncementColor = "GREEN"
	Orange  AnnouncementColor = "ORANGE"
	Purple  AnnouncementColor = "PURPLE"
)

func (AnnouncementColor) RGBHex

func (a AnnouncementColor) RGBHex() string

func (AnnouncementColor) String

func (a AnnouncementColor) String() string

type AnnouncementMessage

type AnnouncementMessage struct {
	UserNotice
	ParamColor AnnouncementColor
	Message    string
}

type AnonGiftPaidUpgradeMessage

type AnonGiftPaidUpgradeMessage struct {
	UserNotice
	PromoGiftTotal int
	PromoName      string
}

type Badge

type Badge struct {
	Name    string
	Version string
}

func (Badge) String

func (b Badge) String() string

type Chat

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

func NewChat

func NewChat(logger zerolog.Logger, accountProvider AccountProvider, accountID string) *Chat

func (*Chat) ConnectWithRetry

func (c *Chat) ConnectWithRetry(ctx context.Context, messages <-chan IRCer) (<-chan IRCer, <-chan error)

type ClearChat

type ClearChat struct {
	BanDuration     *int // in seconds
	RoomID          string
	ChannelUserName string
	TargetUserID    *string
	TMISentTS       time.Time
	UserName        *string
}

func (*ClearChat) IRC

func (c *ClearChat) IRC() string

type ClearMessage

type ClearMessage struct {
	Login           string
	RoomID          string
	ChannelUserName string
	TargetMsgID     string
	TMISentTS       time.Time
}

func (*ClearMessage) IRC

func (c *ClearMessage) IRC() string

type Emote

type Emote struct {
	ID        string
	Positions []EmotePosition
}

type EmotePosition

type EmotePosition struct {
	Start int
	End   int
}

type GiftPaidUpgradeMessage

type GiftPaidUpgradeMessage struct {
	UserNotice
	PromoGiftTotal int
	PromoName      string
	SenderLogin    string
	SenderName     string
}

type IRCer

type IRCer interface {
	IRC() string
}

IRCer are types that can be turned into an IRC command

func ParseIRC

func ParseIRC(message string) (IRCer, error)

type JoinMessage

type JoinMessage struct {
	Channel string
}

func (JoinMessage) IRC

func (j JoinMessage) IRC() string

type MsgID

type MsgID string
const (
	// UserNotice
	Sub                 MsgID = "sub"
	ReSub               MsgID = "resub"
	SubGift             MsgID = "subgift"
	SubMysteryGift      MsgID = "submysterygift"
	GiftPaidUpgrade     MsgID = "giftpaidupgrade"
	RewardGift          MsgID = "rewardgift"
	AnonGiftPaidUpgrade MsgID = "anongiftpaidupgrade"
	Raid                MsgID = "raid"
	UnRaid              MsgID = "unraid"
	Ritual              MsgID = "ritual"
	BitsBadgeTier       MsgID = "bitsbadgetier"
	Announcement        MsgID = "announcement"
)

type Notice

type Notice struct {
	ChannelUserName string
	Message         string
	MsgID           MsgID

	FakeTimestamp time.Time
}

func (*Notice) IRC

func (n *Notice) IRC() string

type PartMessage

type PartMessage struct {
	Channel string
}

func (PartMessage) IRC

func (p PartMessage) IRC() string

type PingMessage

type PingMessage struct{}

func (PingMessage) IRC

func (p PingMessage) IRC() string

type PongMessage

type PongMessage struct{}

func (PongMessage) IRC

func (p PongMessage) IRC() string

type PrivateMessage

type PrivateMessage struct {
	BadgeInfo   []Badge
	Badges      []Badge
	Bits        int
	Color       string
	DisplayName string
	Emotes      []Emote
	ID          string
	Mod         bool
	FirstMsg    bool

	// Hype chat
	PaidAmount          int
	PaidCurrency        string
	PaidExponent        int
	PaidLevel           string
	PaidIsSystemMessage bool

	// Reply
	ParentMsgID           string
	ParentUserID          string
	ParentUserLogin       string
	ParentDisplayName     string
	ParentMsgBody         string
	ThreadParentMsgID     string
	ThreadParentUserLogin string

	RoomID          string
	ChannelUserName string
	LoginName       string
	Subscriber      bool
	TMISentTS       time.Time
	Turbo           bool
	UserID          string
	UserType        UserType
	VIP             bool

	// Joined chat rooms
	SourceID     string
	SourceRoomID string
	SourceBadges []Badge

	Message string
}

func (*PrivateMessage) Clone

func (p *PrivateMessage) Clone() *PrivateMessage

func (*PrivateMessage) IRC

func (p *PrivateMessage) IRC() string

func (PrivateMessage) MarshalEasyJSON

func (v PrivateMessage) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (*PrivateMessage) UnmarshalEasyJSON

func (v *PrivateMessage) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

type RaidMessage

type RaidMessage struct {
	UserNotice
	DisplayName string
	Login       string
	ViewerCount int
}

type RetryReachedError

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

func (RetryReachedError) Error

func (e RetryReachedError) Error() string

func (RetryReachedError) Unwrap

func (e RetryReachedError) Unwrap() error

type RitualMessage

type RitualMessage struct {
	UserNotice
	RitualName string
	Message    string
}

type RoomState

type RoomState struct {
	EmoteOnly       *bool
	FollowersOnly   *int
	R9K             *bool
	RoomID          string
	ChannelUserName string
	Slow            *int
	SubsOnly        *bool
}

Only the changed values are set RoomState does not represent the final state

func (*RoomState) IRC

func (r *RoomState) IRC() string

type SubGiftMessage

type SubGiftMessage struct {
	UserNotice
	Months             int
	ReceiptDisplayName string
	RecipientID        string
	RecipientUserName  string
	SubPlan            SubPlan
	SubPlanName        string
	GiftMonths         int
}

type SubMessage

type SubMessage struct {
	UserNotice
	Message           string
	CumulativeMonths  int
	ShouldShareStreak bool
	StreakMonths      int
	SubPlan           SubPlan
	SubPlanName       string
}

type SubPlan

type SubPlan string
const (
	Prime SubPlan = "Prime"
	Tier1 SubPlan = "1000"
	Tier2 SubPlan = "2000"
	Tier3 SubPlan = "3000"
)

func (SubPlan) String

func (s SubPlan) String() string

type UserNotice

type UserNotice struct {
	BadgeInfo       []Badge
	Badges          []Badge
	Color           string
	DisplayName     string
	Emotes          []Emote
	ID              string
	Login           string
	Mod             bool
	MsgID           MsgID
	RoomID          string
	ChannelUserName string
	Subscriber      bool
	SystemMsg       string
	TMISentTS       time.Time
	Turbo           bool
	UserID          string
	UserType        UserType
}

func (*UserNotice) IRC

func (u *UserNotice) IRC() string

type UserState

type UserState struct {
	BadgeInfo       []Badge
	Badges          []Badge
	Color           string
	DisplayName     string
	ChannelUserName string
	EmoteSets       []string
	ID              string
	Subscriber      bool
	Turbo           bool
	UserType        UserType
}

func (*UserState) IRC

func (u *UserState) IRC() string

type UserType

type UserType string
const (
	Empty     UserType = "" // normal user
	Admin     UserType = "admin"
	GlobalMod UserType = "global_mod"
	Staff     UserType = "staff"
)

type Whisper

type Whisper struct {
	Badges      []Badge
	Color       string
	DisplayName string
	Emotes      []Emote
	ID          string
	ThreadID    string
	Turbo       bool
	UserID      string
	UserType    UserType
	Message     string
}

func (*Whisper) IRC

func (w *Whisper) IRC() string

Jump to

Keyboard shortcuts

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