tgc

package
v0.0.0-...-7750491 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2024 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInValidChannelID       = errors.New("invalid channel id")
	ErrInvalidChannelMessages = errors.New("invalid channel messages")
)

Functions

func AuthClient

func AuthClient(ctx context.Context, config *config.TGConfig, sessionStr string, middlewares ...telegram.Middleware) (*telegram.Client, error)

func BotClient

func BotClient(ctx context.Context, KV kv.KV, config *config.TGConfig, token string, middlewares ...telegram.Middleware) (*telegram.Client, error)

func CalculateChunkSize

func CalculateChunkSize(start, end int64) int64

func DeleteMessages

func DeleteMessages(ctx context.Context, client *telegram.Client, channelId int64, ids []int) error

func GetBotInfo

func GetBotInfo(ctx context.Context, KV kv.KV, config *config.TGConfig, token string) (*types.BotInfo, error)

func GetChannelById

func GetChannelById(ctx context.Context, client *tg.Client, channelId int64) (*tg.InputChannel, error)

func GetChunk

func GetChunk(ctx context.Context, client *tg.Client, location tg.InputFileLocationClass, offset int64, limit int64) ([]byte, error)

func GetLocation

func GetLocation(ctx context.Context, client *tg.Client, channelId int64, partId int64) (location *tg.InputDocumentFileLocation, err error)

func GetMediaContent

func GetMediaContent(ctx context.Context, client *tg.Client, location tg.InputFileLocationClass) (*bytes.Buffer, error)

func GetMessages

func GetMessages(ctx context.Context, client *tg.Client, ids []int, channelId int64) ([]tg.MessageClass, error)

func Middlewares

func Middlewares(config *config.TGConfig, retries int) []telegram.Middleware

func New

func New(ctx context.Context, config *config.TGConfig, handler telegram.UpdateHandler, storage session.Storage, middlewares ...telegram.Middleware) (*telegram.Client, error)

func NoAuthClient

func NoAuthClient(ctx context.Context, config *config.TGConfig, handler telegram.UpdateHandler, storage session.Storage) (*telegram.Client, error)

func RunWithAuth

func RunWithAuth(ctx context.Context, client *telegram.Client, token string, f func(ctx context.Context) error) error

Types

type BotWorker

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

func NewBotWorker

func NewBotWorker() *BotWorker

func (*BotWorker) Next

func (w *BotWorker) Next(channelID int64) (string, int)

func (*BotWorker) Set

func (w *BotWorker) Set(bots []string, channelID int64)

type Client

type Client struct {
	Tg     *telegram.Client
	Stop   StopFunc
	Status ClientStatus
	UserID string
}

type ClientStatus

type ClientStatus int
const (
	StatusIdle ClientStatus = iota
	StatusBusy
)

type Option

type Option interface {
	// contains filtered or unexported methods
}

func WithBotToken

func WithBotToken(token string) Option

func WithContext

func WithContext(ctx context.Context) Option

type StopFunc

type StopFunc func() error

func Connect

func Connect(client *telegram.Client, options ...Option) (StopFunc, error)

type StreamWorker

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

func NewStreamWorker

func NewStreamWorker(cnf *config.Config, kv kv.KV, logger *zap.SugaredLogger) *StreamWorker

func (*StreamWorker) DecActiveStreams

func (w *StreamWorker) DecActiveStreams() error

func (*StreamWorker) IncActiveStream

func (w *StreamWorker) IncActiveStream() error

func (*StreamWorker) Next

func (w *StreamWorker) Next(channelID int64) (*Client, error)

func (*StreamWorker) Set

func (w *StreamWorker) Set(bots []string, channelID int64)

Jump to

Keyboard shortcuts

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