garoo

package
v0.0.0-...-9b95192 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const TextCategory = "_"

Variables

This section is empty.

Functions

This section is empty.

Types

type Author

type Author struct {
	ID          string `json:"id"`
	ScreenName  string `json:"screen_name"`
	Name        string `json:"name,omitempty"`
	Description string `json:"description,omitempty"`
	Avator      string `json:"avator,omitempty"`
	Provider    string `json:"provider"`
}

type Garoo

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

func New

func New(options Options) *Garoo

func (*Garoo) SaveConfig

func (g *Garoo) SaveConfig() error

func (*Garoo) Start

func (g *Garoo) Start() (err error)

func (*Garoo) Stop

func (g *Garoo) Stop() (err error)

type Handler

type Handler func(*Message, Receiver)

type Media

type Media struct {
	Type MediaType `json:"type"`
	URL  string    `json:"url"`
}

type MediaType

type MediaType string
const (
	MediaTypePhoto MediaType = "photo"
	MediaTypeVideo MediaType = "video"
)

type Message

type Message struct {
	ID        string    `json:"id"`
	Timestamp time.Time `json:"timestamp"`
	Content   string    `json:"content"`
}

type MockProvider

type MockProvider struct {
	NameFunc      func() string
	InitFunc      func(string) error
	LoginFunc     func(string) (string, error)
	CheckFunc     func(string) bool
	GetPostFunc   func(context.Context, string) (*Post, error)
	GetConfigFunc func() string
}

func (*MockProvider) Check

func (p *MockProvider) Check(u string) bool

func (*MockProvider) GetConfig

func (p *MockProvider) GetConfig() string

func (*MockProvider) GetPost

func (p *MockProvider) GetPost(ctx context.Context, url string) (*Post, error)

func (*MockProvider) Init

func (p *MockProvider) Init(conf string) error

func (*MockProvider) Login

func (p *MockProvider) Login(code string) (string, error)

func (*MockProvider) Name

func (p *MockProvider) Name() string

type MockReceiver

type MockReceiver struct {
	NameFunc        func() string
	AddHandlerFunc  func(Handler)
	PostMessageFunc func(PostMessageRequest) error
	StartFunc       func() error
	StopFunc        func() error
	SaveConfigFunc  func(any) error
	LoadConfigFunc  func(any) error
}

func (*MockReceiver) AddHandler

func (r *MockReceiver) AddHandler(h Handler)

func (*MockReceiver) LoadConfig

func (r *MockReceiver) LoadConfig(config any) error

func (*MockReceiver) Name

func (r *MockReceiver) Name() string

func (*MockReceiver) PostMessage

func (r *MockReceiver) PostMessage(req PostMessageRequest) error

func (*MockReceiver) SaveConfig

func (r *MockReceiver) SaveConfig(config any) error

func (*MockReceiver) Start

func (r *MockReceiver) Start() error

func (*MockReceiver) Stop

func (r *MockReceiver) Stop() error

type MockStore

type MockStore struct {
	NameFunc      func() string
	InitFunc      func(string) error
	SaveFunc      func(*Post) error
	LoginFunc     func(string) (string, error)
	GetConfigFunc func() string
}

func (*MockStore) GetConfig

func (s *MockStore) GetConfig() string

func (*MockStore) Init

func (s *MockStore) Init(c string) error

func (*MockStore) Login

func (s *MockStore) Login(code string) (string, error)

func (*MockStore) Name

func (s *MockStore) Name() string

func (*MockStore) Save

func (s *MockStore) Save(p *Post) error

type Options

type Options struct {
	Receivers    []Receiver
	Providers    []Provider
	Stores       []Store
	MainReceiver Receiver
	Context      context.Context
}

type Post

type Post struct {
	ID        string    `json:"id"`
	Provider  string    `json:"provider"`
	URL       string    `json:"url"`
	Timestamp time.Time `json:"timestamp"`
	Content   string    `json:"content"`
	Author    Author    `json:"author"`
	Media     []Media   `json:"media,omitempty"`
	Category  string    `json:"category,omitempty"`
	Tags      []string  `json:"tags,omitempty"`
}

func (*Post) IsSpecialCategory

func (post *Post) IsSpecialCategory() bool

func (*Post) IsText

func (post *Post) IsText() bool

type PostMessageRequest

type PostMessageRequest struct {
	Message        string
	MentionToUser  bool
	ReplyToMessage string
}

type Provider

type Provider interface {
	Init(string) error
	Login(string) (string, error)
	Name() string
	Check(url string) bool
	GetPost(ctx context.Context, url string) (*Post, error)
	GetConfig() string
}

type Receiver

type Receiver interface {
	Name() string
	AddHandler(Handler)
	PostMessage(PostMessageRequest) error
	Start() error
	Stop() error
	SaveConfig(any) error
	LoadConfig(any) error
}

type Seed

type Seed struct {
	URL      string   `json:"url"`
	Provider string   `json:"provider"`
	Category string   `json:"category,omitempty"`
	Tags     []string `json:"tags,omitempty"`
}

func SeedFrom

func SeedFrom(url, provider, message string) Seed

type Store

type Store interface {
	Name() string
	Init(string) error
	Save(*Post) error
	Login(string) (string, error)
	GetConfig() string
}

Jump to

Keyboard shortcuts

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