actions

package
v0.0.0-...-981a9ea Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2020 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Check

func Check(a Action) error

Types

type Action

type Action interface {
	GetOptions() *Options
	Run(*Event) error
}

type Actions

type Actions []Action

func GetAll

func GetAll() Actions

type Event

type Event struct {
	Log           zerolog.Logger
	Twitch        *twitch.Client
	State         *state.Client
	Weather       *openweather.Client
	Location      *nominatim.Client
	ImgurClientID string
	BotName       string
	Debug         bool

	Msg   *twitch.PrivateMessage
	Match []string

	Sleeping bool

	Perm Permission

	Skipped bool
}

func (*Event) HasPermission

func (e *Event) HasPermission(perm Permission) bool

HasPermission compares perm with the permission level of the sender and reports wheather the sender has a permission of at least perm.

func (*Event) Init

func (e *Event) Init()

Init sets some internal values like the permission of the sender.

func (*Event) IsBot

func (e *Event) IsBot() bool

IsBot reports wheather the message was sent by a bot. Currently it compares the name of the sender with a list of know bots. TODO: check in other places eg. badges

func (*Event) IsBroadcaster

func (e *Event) IsBroadcaster() bool

IsBroadcaster reports wheather the sender is the owner of the current channel.

func (*Event) IsCoolingDown

func (e *Event) IsCoolingDown() bool

IsCoolingDown reports wheather the command is available or if it is cooling down. This could be because of a user, channel or command cooldown. TODO: implement

func (*Event) IsInBotChannel

func (e *Event) IsInBotChannel() bool

IsInBotChannel reports wheather the current channel is owned by the bot.

func (*Event) IsModerator

func (e *Event) IsModerator() bool

IsModerator reports wheather the sender is a moderator in the current channel.

func (*Event) IsOwner

func (e *Event) IsOwner() bool

IsOwner reports wheather the sender is the bots owner.

func (*Event) IsRegular

func (e *Event) IsRegular() bool

IsRegular reports wheather the sender is a regular. TODO: implement

func (*Event) IsSubscriber

func (e *Event) IsSubscriber() bool

IsSubscriber reports wheather the sender is a subscriber in the current channel.

func (*Event) Say

func (e *Event) Say(message string)

Say sends message to the current channel.

func (*Event) Skip

func (e *Event) Skip()

Skip skips this command and allows other commands to run.

type Options

type Options struct {
	Name             string
	Re               *regexp.Regexp
	Sleepless        bool
	Perm             Permission
	Disabled         bool
	DisabledChannels map[string]bool

	UserCooldown    time.Duration
	ChannelCooldown time.Duration
	GlobalCooldown  time.Duration
}

type Permission

type Permission int

Permission is a int

const (
	Everyone Permission = iota
	Subscriber
	Regular
	Moderator
	Broadcaster
	Owner
)

Possible values for Permission.

func (Permission) String

func (i Permission) String() string

Jump to

Keyboard shortcuts

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