Documentation
¶
Index ¶
- Constants
- Variables
- func NewApiService(repo *repositories.Repositories, channelManager ChannelManager, ...) *apiService
- func NewJobExecutor(apiSvc *apiService) queue.Executor
- func NewRawService(api *apiService) *rawService
- type ChannelManager
- type JobClientRef
- func (r *JobClientRef) Insert(ctx context.Context, args river.JobArgs, opts *river.InsertOpts) (*rivertype.JobInsertResult, error)
- func (r *JobClientRef) JobCancel(ctx context.Context, jobID int64) (*rivertype.JobRow, error)
- func (r *JobClientRef) JobDelete(ctx context.Context, id int64) (*rivertype.JobRow, error)
- func (r *JobClientRef) JobGet(ctx context.Context, id int64) (*rivertype.JobRow, error)
- func (r *JobClientRef) JobList(ctx context.Context, params *river.JobListParams) (*river.JobListResult, error)
- func (r *JobClientRef) JobUpdate(ctx context.Context, id int64, params *river.JobUpdateParams) (*rivertype.JobRow, error)
- func (r *JobClientRef) Set(target jobClient)
- type PeriodicJobRegistryRef
- func (r *PeriodicJobRegistryRef) AddMany(periodicJobs []*river.PeriodicJob) []rivertype.PeriodicJobHandle
- func (r *PeriodicJobRegistryRef) AddSafely(periodicJob *river.PeriodicJob) (rivertype.PeriodicJobHandle, error)
- func (r *PeriodicJobRegistryRef) RemoveByID(id string) bool
- func (r *PeriodicJobRegistryRef) Set(target periodicJobRegistry)
- type TelegramAuthorization
- type TelegramClient
- type TelegramService
- type TelegramUser
- type UploadPool
Constants ¶
View Source
const ( TelegramOpStream = "stream" TelegramOpUpload = "upload" )
Variables ¶
View Source
var ( ErrInvalidPassword = errors.New("invalid password") ErrEmptyAuth = errors.New("empty auth") )
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 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 (r *JobClientRef) Insert(ctx context.Context, args river.JobArgs, opts *river.InsertOpts) (*rivertype.JobInsertResult, 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 (r *PeriodicJobRegistryRef) AddSafely(periodicJob *river.PeriodicJob) (rivertype.PeriodicJobHandle, error)
func (*PeriodicJobRegistryRef) RemoveByID ¶
func (r *PeriodicJobRegistryRef) RemoveByID(id string) bool
func (*PeriodicJobRegistryRef) Set ¶
func (r *PeriodicJobRegistryRef) Set(target periodicJobRegistry)
type TelegramAuthorization ¶
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 ¶
Click to show internal directories.
Click to hide internal directories.