recordings

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: May 18, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const RecordingHeader = "🎓 Записи занятий"

RecordingHeader is the marker line the bot uses for recording posts.

Variables

This section is empty.

Functions

func Format

func Format(r Recording) string

Format renders a single recording in the canonical bot-style block.

func FormatLine

func FormatLine(r Recording) string

FormatLine is a compact one-line summary used in pickers.

Types

type Permalinker

type Permalinker interface {
	Permalink(postID string) string
}

Permalinker turns a post ID into a chat permalink. Optional — usecase works without it, recordings just won't have PostURL filled.

type PostSource

type PostSource interface {
	LoadPosts(ctx context.Context) ([]RawPost, error)
}

PostSource is implemented by any store that can hand back the posts to scan. The implementation is free to read from local cache or remote API.

type RawPost

type RawPost struct {
	ID       string
	Message  string
	CreateAt time.Time
}

RawPost is the minimal shape the usecase needs from any post source.

type Recording

type Recording struct {
	PostID    string
	PostURL   string    // mattermost permalink to the source post, optional
	PostedAt  time.Time // post create time
	Date      time.Time // lesson date (day precision); zero if not parsed
	Subject   string    // "Пара:" value
	StartTime string    // "HH:MM" or empty
	EndTime   string    // "HH:MM" or empty
	Links     []RecordingLink
}

Recording is one extracted lesson recording.

func Parse

func Parse(message string, posted time.Time) []Recording

Parse extracts zero or more recordings from a post message. `posted` is the create time of the post and is used as a fallback when the per-lesson date in the header is missing.

type RecordingLink struct {
	URL  string
	Size string // raw size string from the bot, e.g. "24,9 МБ"; empty if missing
}

RecordingLink is a single playback/download URL.

type UseCase

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

UseCase wraps a PostSource with parsing + search logic.

func New

func New(src PostSource) *UseCase

func (*UseCase) All

func (uc *UseCase) All(ctx context.Context) ([]Recording, error)

All returns every recording found in the source, newest first.

func (*UseCase) ForCourse

func (uc *UseCase) ForCourse(ctx context.Context, courseName string) ([]Recording, error)

ForCourse is a convenience wrapper over Search intended for course summaries: matches recordings whose subject contains the course name.

func (*UseCase) Search

func (uc *UseCase) Search(ctx context.Context, query string) ([]Recording, error)

Search returns recordings whose subject contains query (case-insensitive). An empty query returns all recordings.

func (*UseCase) WithPermalinker

func (uc *UseCase) WithPermalinker(p Permalinker) *UseCase

WithPermalinker attaches a Permalinker so parsed recordings carry PostURL.

Jump to

Keyboard shortcuts

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