services

package
v0.0.0-...-e65fbe1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: MIT Imports: 78 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TelegramOpStream = "stream"
	TelegramOpUpload = "upload"
)

Variables

View Source
var (
	ErrShareNotFound   = errors.New("share not found")
	ErrInvalidPassword = errors.New("invalid password")
	ErrEmptyAuth       = errors.New("empty auth")
	ErrShareExpired    = errors.New("share expired")
	ErrInvalidShareTok = errors.New("invalid share token")
)
View Source
var (
	ErrUploadFailed = errors.New("upload failed")
)
View Source
var (
	ErrorStreamAbandoned = errors.New("stream abandoned")
)

Functions

func NewApiService

func NewApiService(repo *repositories.Repositories,
	channelManager ChannelManager,
	cnf *config.ServerCmdConfig,
	cache cache.Cacher,
	telegram TelegramService,
	events events.EventBroadcaster,
	jobs jobClient,
	periodicJobs periodicJobRegistry) *apiService

func NewJobExecutor

func NewJobExecutor(apiSvc *apiService) queue.Executor

func NewRawService

func NewRawService(api *apiService) *rawService

Types

type ChannelManager

type ChannelManager interface {
	CurrentChannel(ctx context.Context, userID int64) (int64, error)
	BotTokens(ctx context.Context, userID int64) ([]string, error)
	ChannelLimitReached(channelID int64) bool
	CreateNewChannel(ctx context.Context, newChannelName string, userID int64, setDefault bool) (int64, error)
	AddBotsToChannel(ctx context.Context, userID int64, channelID int64, botsTokens []string, save bool) error
}

type JobClientRef

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

func NewJobClientRef

func NewJobClientRef() *JobClientRef

func (*JobClientRef) Insert

func (*JobClientRef) JobCancel

func (r *JobClientRef) JobCancel(ctx context.Context, jobID int64) (*rivertype.JobRow, error)

func (*JobClientRef) JobDelete

func (r *JobClientRef) JobDelete(ctx context.Context, id int64) (*rivertype.JobRow, error)

func (*JobClientRef) JobGet

func (r *JobClientRef) JobGet(ctx context.Context, id int64) (*rivertype.JobRow, error)

func (*JobClientRef) JobList

func (r *JobClientRef) JobList(ctx context.Context, params *river.JobListParams) (*river.JobListResult, error)

func (*JobClientRef) JobUpdate

func (r *JobClientRef) JobUpdate(ctx context.Context, id int64, params *river.JobUpdateParams) (*rivertype.JobRow, error)

func (*JobClientRef) Set

func (r *JobClientRef) Set(target jobClient)

type PeriodicJobRegistryRef

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

func NewPeriodicJobRegistryRef

func NewPeriodicJobRegistryRef() *PeriodicJobRegistryRef

func (*PeriodicJobRegistryRef) AddMany

func (r *PeriodicJobRegistryRef) AddMany(periodicJobs []*river.PeriodicJob) []rivertype.PeriodicJobHandle

func (*PeriodicJobRegistryRef) AddSafely

func (*PeriodicJobRegistryRef) RemoveByID

func (r *PeriodicJobRegistryRef) RemoveByID(id string) bool

func (*PeriodicJobRegistryRef) Set

func (r *PeriodicJobRegistryRef) Set(target periodicJobRegistry)

type TelegramAuthorization

type TelegramAuthorization struct {
	DateCreated int32
	Current     bool
	AppName     string
	Country     string
	OfficialApp bool
}

type TelegramClient

type TelegramClient interface {
	API() *tg.Client
	Run(ctx context.Context, f func(ctx context.Context) error) error
	RandInt64() (int64, error)
	Self(ctx context.Context) (*TelegramUser, error)
	QRLogin(ctx context.Context, loggedIn qrlogin.LoggedIn, onToken func(ctx context.Context, tokenURL string) error) (*TelegramUser, error)
	SendCode(ctx context.Context, phoneNo string) (string, error)
	SignIn(ctx context.Context, phoneNo, phoneCode, phoneCodeHash string) (*TelegramUser, error)
	Password(ctx context.Context, password string) (*TelegramUser, error)
}

type TelegramService

type TelegramService interface {
	AuthClient(ctx context.Context, sessionStr string, retries int) (TelegramClient, error)
	BotClient(ctx context.Context, token string, retries int) (TelegramClient, error)
	SelectBotToken(ctx context.Context, operation string, userID int64, tokens []string) (string, int, error)
	NewQRLogin() (tg.UpdateDispatcher, qrlogin.LoggedIn)
	NoAuthClient(ctx context.Context, dispatcher tg.UpdateDispatcher, storage session.Storage) (TelegramClient, error)
	RunWithAuth(ctx context.Context, client TelegramClient, token string, f func(ctx context.Context) error) error
	LogOut(ctx context.Context, client TelegramClient) error
	ListAuthorizations(ctx context.Context, client TelegramClient) ([]TelegramAuthorization, error)
	DeleteChannel(ctx context.Context, client TelegramClient, channelID int64) (storage.PeerKey, error)
	SyncDialogs(ctx context.Context, client TelegramClient, peerStorage storage.PeerStorage) error
	GetProfilePhoto(ctx context.Context, client TelegramClient) ([]byte, int64, bool, error)
	NewUploadPool(ctx context.Context, client TelegramClient, size int64, retries int) (UploadPool, error)
	GetMessages(ctx context.Context, client TelegramClient, ids []int, channelID int64) ([]tg.MessageClass, error)
	GetParts(ctx context.Context, client TelegramClient, channelID int64, fileParts []api.Part, encrypted bool) ([]types.Part, error)
	CopyFileParts(ctx context.Context, client TelegramClient, sourceChannelID int64, destinationChannelID int64, sourceParts []api.Part) ([]api.Part, error)
	UploadPart(ctx context.Context, apiClient *tg.Client, channelID int64, partName string, fileStream io.Reader, fileSize int64, threads int) (int, int64, error)
	ChannelByID(ctx context.Context, client TelegramClient, channelID int64) (*tg.InputChannel, error)
	ChannelByIDRaw(ctx context.Context, api *tg.Client, channelID int64) (*tg.InputChannel, error)
	GetChannelFull(ctx context.Context, client TelegramClient, channelID int64) (*tg.Channel, error)
	GetMediaContent(ctx context.Context, client TelegramClient, location tg.InputFileLocationClass) (*bytes.Buffer, error)
	IsNoDefaultChannelError(err error) bool
	IsPasswordAuthNeeded(err error) bool
	IsSessionPasswordNeeded(err error) bool
	IsAuthKeyUnregistered(err error) bool
}

func NewTelegramService

func NewTelegramService(repo *repositories.Repositories, cache cache.Cacher, cnf *config.TGConfig, botSelector tgc.BotSelector) TelegramService

type TelegramUser

type TelegramUser struct {
	ID        int64
	Username  string
	FirstName string
	LastName  string
	Premium   bool
}

type UploadPool

type UploadPool interface {
	Default(ctx context.Context) *tg.Client
	Close()
}

Jump to

Keyboard shortcuts

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