Documentation ¶
Index ¶
- func ChannelTopic(e Event) error
- func CooldownMessageFromError(err error) string
- func Execute(ctx context.Context, cfg config.Config) error
- func FaveList(e Event) error
- func FaveTrack(e Event) error
- func FindNamedSubmatches(re *regexp.Regexp, s string) map[string]string
- func Fmt(message string, args ...interface{}) string
- func FormatDuration(t time.Duration, truncate time.Duration) string
- func FormatLongDuration(t time.Duration) string
- func FormatPlaybackDuration(t time.Duration) string
- func FormatPlaybackDurationHours(t time.Duration) string
- func HasAccess(c *girc.Client, e girc.Event) bool
- func HasDeveloperAccess(e Event) (bool, error)
- func HasStreamAccess(c *girc.Client, e girc.Event) bool
- func IsAuthed(e Event) bool
- func KillStreamer(e Event) error
- func LastPlayed(e Event) error
- func LastRequestInfo(e Event) error
- func LuckyTrackRequest(e Event) error
- func NewAnnounceService(cfg config.Config, storage radio.StorageService, bot *Bot) radio.AnnounceService
- func NewGRPCServer(ctx context.Context, service radio.AnnounceService) (*grpc.Server, error)
- func NowPlaying(e Event) error
- func Pluralf(format string, amount int64) string
- func RandomTrackRequest(e Event) error
- func RegisterCommandHandlers(ctx context.Context, b *Bot) error
- func RegisterCommonHandlers(b *Bot, c *girc.Client) error
- func RequestTrack(e Event) error
- func SearchTrack(e Event) error
- func StreamerQueue(e Event) error
- func StreamerQueueLength(e Event) error
- func StreamerUserInfo(e Event) error
- func ThreadURL(e Event) error
- func TrackInfo(e Event) error
- func TrackTags(e Event) error
- type Arguments
- type Bot
- type CommonHandlers
- type Event
- type HandlerFn
- type RegexHandler
- type RegexHandlers
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChannelTopic ¶
func CooldownMessageFromError ¶
CooldownMessageFromError returns a friendlier, coloured error message for cooldown related errors
func Execute ¶
Execute executes the ircbot with the context and configuration given. it returns with any error that occurs; Execution can be interrupted by canceling the context given.
func FindNamedSubmatches ¶
FindNamedSubmatches runs re.FindStringSubmatch(s) and only returns the groups that are named in the regexp
func FormatDuration ¶
FormatDuration formats a Duration similar to Duration.String except it adds a possible month and day value to the front if available. Such that instead of the form "72h3m0.5s" this returns "3d3m0.5s".
The truncate argument indicates the smallest unit returned in the string
func FormatLongDuration ¶
FormatLongDuration formats a Duration in a long form with each unit spelled out completely and spaced properly. For example a duration of 1d5h22s would be formatted as `1 day, 5 hours, 22 seconds`
func FormatPlaybackDuration ¶
FormatPlaybackDuration formats a Duration in the form mm:ss where mm are minutes and ss are seconds.
func FormatPlaybackDurationHours ¶
FormatPlaybackDurationHours is similar to FormatPlaybackDuration but also includes the hour part, making it "hh:mm:ss"
func HasAccess ¶
HasAccess checks if the user that send the PRIVMSG to us has access +h or higher in the channel it came from; HasAccess panics if the event is not PRIVMSG
func HasDeveloperAccess ¶
func HasStreamAccess ¶
HasStreamAccess is similar to HasAccess but also includes special casing for streamers that don't have channel access, but do have the authorization to access the stream
func KillStreamer ¶
func LastPlayed ¶
func LastRequestInfo ¶
func LuckyTrackRequest ¶
func NewAnnounceService ¶
func NewAnnounceService(cfg config.Config, storage radio.StorageService, bot *Bot) radio.AnnounceService
func NewGRPCServer ¶
func NowPlaying ¶
func Pluralf ¶
Pluralf returns fmt.Sprintf(format, amount) but returns the string without its last character when amount == 1
func RandomTrackRequest ¶
func RegisterCommonHandlers ¶
RegisterCommonHandlers registers non-command handlers that are required for a functional client
func RequestTrack ¶
func SearchTrack ¶
func StreamerQueue ¶
func StreamerQueueLength ¶
func StreamerUserInfo ¶
Types ¶
type Arguments ¶
Arguments is a map of key:value pairs from the named capturing groups used in the regular expression used for the command
type Bot ¶
type Bot struct { config.Config Storage radio.StorageService // interfaces to other components Searcher radio.SearchService // Values used by commands StatusValue *util.Value[radio.Status] ListenersValue *util.Value[radio.Listeners] UserValue *util.Value[*radio.User] // contains filtered or unexported fields }
type CommonHandlers ¶
type CommonHandlers struct {
*Bot
}
CommonHandlers groups all handlers that should always be registered to function as basic irc bot
func (CommonHandlers) AuthenticateWithNickServ ¶
func (h CommonHandlers) AuthenticateWithNickServ(c *girc.Client, e girc.Event)
AuthenticateWithNickServ tries to authenticate with nickserv with the password configured
func (CommonHandlers) JoinDefaultChannels ¶
func (h CommonHandlers) JoinDefaultChannels(c *girc.Client, _ girc.Event)
JoinDefaultChannels joins all the channels listed in the configuration file
type Event ¶
type Event struct { Ctx context.Context Storage radio.StorageService girc.Event Arguments Arguments Bot *Bot Client *girc.Client }
Event is a collection of parameters to handler functions, all fields are guaranteed to be populated when passed through a RegexHandler
func (Event) ArgumentTrack ¶
ArgumentTrack returns the key given interpreted as a radio.TrackID and returns the song associated with it.
func (Event) CurrentTrack ¶
CurrentTrack returns the currently playing song on the main stream configured
func (Event) Echo ¶
Echo sends either a PRIVMSG to a channel or a NOTICE to a user based on the prefix used when running the command
func (Event) EchoPrivate ¶
EchoPrivate always sends a message as a NOTICE to the user that invoked the event
func (Event) EchoPublic ¶
EchoPublic always sends a message as a PRIVMSG to the channel that the event was invoked on
type RegexHandler ¶
type RegexHandler struct {
// contains filtered or unexported fields
}
type RegexHandlers ¶
type RegexHandlers struct {
// contains filtered or unexported fields
}
RegexHandlers is a collection of handlers that are triggered based on a regular expression.
An IRC events last parameter is used to match against.
func NewRegexHandlers ¶
func NewRegexHandlers(ctx context.Context, bot *Bot, handlers ...RegexHandler) RegexHandlers