reddit

package
v4.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2024 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PaywallButton

func PaywallButton(feedID feed.ID, subreddit, thingID string) telegram.Button

func PreferenceButtons

func PreferenceButtons(subreddit, thingID string, likes, dislikes int64, paywall bool) []telegram.Button

Types

type Score

type Score struct {
	First          *time.Time
	LikedThings    int
	DislikedThings int
	Likes          int
	Dislikes       int
}

type Storage

type Storage[C core.StorageContext] struct {
	StorageInterface
}

func (*Storage[C]) Include

func (s *Storage[C]) Include(ctx context.Context, app apfel.MixinApp[C]) error

func (Storage[C]) String

func (s Storage[C]) String() string

type StorageInterface

type StorageInterface interface {
	feed.Storage
	feed.EventStorage
	SaveThings(ctx context.Context, things []reddit.Thing) error
	RedditTx(ctx context.Context, body func(tx StorageTx) error) error
}

type StorageTx

type StorageTx interface {
	Score(feedID feed.ID, thingIDs []string) (*Score, error)
	GetPercentile(subreddit string, top float64) (int, error)
	GetFreshThingIDs(ids colf.Set[string]) (colf.Set[string], error)
	DeleteStaleThings(until time.Time) (int64, error)
}

type Subreddit

type Subreddit[C SubredditContext] struct {
	// contains filtered or unexported fields
}

func (*Subreddit[C]) BeforeResume

func (v *Subreddit[C]) BeforeResume(ctx context.Context, header feed.Header) error

func (*Subreddit[C]) Include

func (v *Subreddit[C]) Include(ctx context.Context, app apfel.MixinApp[C]) error

func (*Subreddit[C]) Parse

func (v *Subreddit[C]) Parse(ctx context.Context, ref string, options []string) (*feed.Draft, error)

func (*Subreddit[C]) Refresh

func (v *Subreddit[C]) Refresh(ctx context.Context, header feed.Header, refresh feed.Refresh) error

func (*Subreddit[C]) String

func (v *Subreddit[C]) String() string

type SubredditConfig

type SubredditConfig struct {
	Pacing        SubredditPacingConfig `yaml:"pacing,omitempty" doc:"Settings for controlling pacing based on top ratio."`
	CleanInterval flu.Duration          `yaml:"cleanInterval,omitempty" doc:"How often to clean things from data." default:"24h"`
	ThingTTL      flu.Duration          `yaml:"thingTtl,omitempty" doc:"How long to keep things in database." default:"168h"`
}

type SubredditContext

type SubredditContext interface {
	reddit.Context
	core.MediatorContext
	core.StorageContext
	tapp.Context
	SubredditConfig() SubredditConfig
}

type SubredditData

type SubredditData struct {
	Subreddit     string           `json:"subreddit"`
	SentIDs       colf.Set[string] `json:"sent_ids,omitempty"`
	LastCleanSecs int64            `json:"last_clean,omitempty"`
	Layout        ThingLayout      `json:"layout,omitempty"`
}

type SubredditEventData

type SubredditEventData struct {
	UserID    telegram.ID `json:"user_id" delete:"user_id" count:"-" pre:"user_id"`
	MessageID telegram.ID `json:"message_id" delete:"message_id" count:"message_id" pre:"-"`
	Subreddit string      `json:"subreddit" delete:"-" count:"-" pre:"-"`
	ThingID   string      `json:"thing_id" delete:"-" count:"-" pre:"thing_id"`
}

type SubredditPacingConfig

type SubredditPacingConfig struct {
	Gain    flu.Duration `yaml:"gain,omitempty" doc:"Do not apply pacing during this interval since subscription start." default:"48h"`
	Base    float64      `yaml:"base,omitempty" doc:"Base top ratio to be applied for stable subscriptions." default:"0.01"`
	Min     float64      `yaml:"min,omitempty" doc:"Lowest allowed top ratio."`
	Scale   float64      `` /* 126-byte string literal not displayed */
	Members int64        `yaml:"members,omitempty" doc:"Lowest chat members threshold." default:"300"`
	Batch   int          `yaml:"batch,omitempty" doc:"Max update batch size." default:"1"`
}

type SubredditSuggestions

type SubredditSuggestions[C SubredditSuggestionsContext] struct {
	// contains filtered or unexported fields
}

func (*SubredditSuggestions[C]) Include

func (v *SubredditSuggestions[C]) Include(ctx context.Context, app apfel.MixinApp[C]) error

func (*SubredditSuggestions[C]) Parse

func (v *SubredditSuggestions[C]) Parse(ctx context.Context, ref string, options []string) (*feed.Draft, error)

func (*SubredditSuggestions[C]) Refresh

func (v *SubredditSuggestions[C]) Refresh(ctx context.Context, header feed.Header, refresh feed.Refresh) error

func (SubredditSuggestions[C]) String

func (v SubredditSuggestions[C]) String() string

type SubredditSuggestionsConfig

type SubredditSuggestionsConfig struct {
	Period   flu.Duration `yaml:"period,omitempty" doc:"Period to consider data for." default:"374h"`
	Interval flu.Duration `yaml:"interval,omitempty" doc:"How often to make suggestions." default:"24h"`
}

type SubredditSuggestionsContext

type SubredditSuggestionsContext interface {
	tapp.Context
	core.StorageContext
	core.InterfaceContext
	SubredditSuggestionsConfig() SubredditSuggestionsConfig
}

type SubredditSuggestionsData

type SubredditSuggestionsData struct {
	Ref         string   `json:"ref"`
	FeedID      feed.ID  `json:"chat_id"`
	FiredAtSecs int64    `json:"fired_at"`
	Options     []string `json:"options"`
}

type ThingLayout

type ThingLayout struct {
	HideSubreddit  bool `json:"hide_subreddit,omitempty"`
	HideLink       bool `json:"hide_link,omitempty"`
	ShowAuthor     bool `json:"show_author,omitempty"`
	HideTitle      bool `json:"hide_title,omitempty"`
	ShowText       bool `json:"show_text,omitempty"`
	HideMedia      bool `json:"hide_media,omitempty"`
	HideMediaLink  bool `json:"hide_media_link,omitempty"`
	ShowPaywall    bool `json:"show_paywall,omitempty"`
	ShowPreference bool `json:"show_preference,omitempty"`
}

func (*ThingLayout) WriteHTML

func (l *ThingLayout) WriteHTML(feedID feed.ID, thing reddit.ThingData, mediaRef receiver.MediaRef) feed.WriteHTML

Jump to

Keyboard shortcuts

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