bot

package
v0.1.17 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2023 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package bot is a generated GoMock package.

Index

Constants

View Source
const (
	QueueFetching  = "fetching"
	QueueUploading = "uploading"
)
View Source
const (
	ParseVideoEvent   botstate.EventType = "parse_video"
	GoToDefaultEvent  botstate.EventType = "go_to_default"
	ParsingVideoState botstate.StateType = "parsing_video"
)
View Source
const SendingMessageError = "Oops, something went wrong, try sending the link again"
View Source
const (
	StartCommandText = "start"
)

Variables

View Source
var StartCommandMessage = "Hi, this is a bot" + emoji.Robot.String() + " for downloading videos from youtube\n\n" +
	"Just send a link to the youtube video and follow the further instructions\n" +
	"\n*source code:* [github](https://github.com/robotomize/cribe)"

Functions

This section is empty.

Types

type AMQPBroker

type AMQPBroker struct {
	*amqp.Connection
}

func NewAMQPBroker

func NewAMQPBroker(connection *amqp.Connection) *AMQPBroker

func (*AMQPBroker) Chan

func (a *AMQPBroker) Chan() (AMQPChannel, error)

type AMQPChannel

type AMQPChannel interface {
	Publish(exchange, key string, mandatory, immediate bool, msg amqp.Publishing) error
	QueueDeclare(name string, durable, autoDelete, exclusive, noWait bool, args amqp.Table) (amqp.Queue, error)
	Consume(queue, consumer string, autoAck, exclusive, noLocal, noWait bool, args amqp.Table) (<-chan amqp.Delivery, error)
	Close() error
}

type AMQPConnection

type AMQPConnection interface {
	Chan() (AMQPChannel, error)
	Close() error
}

type Blob

type Blob interface {
	CreateObject(ctx context.Context, bucket, key string, contents []byte) error
	DeleteObject(ctx context.Context, bucket, key string) error
	GetObject(ctx context.Context, bucket, key string) ([]byte, error)
}

type DefaultAction

type DefaultAction struct{}

func (*DefaultAction) Execute

type Dispatcher

type Dispatcher struct {
	Jobs []Job
	// contains filtered or unexported fields
}

func NewDispatcher

func NewDispatcher(env *srvenv.Env, opts ...Option) (*Dispatcher, error)

func (*Dispatcher) Run

func (s *Dispatcher) Run(ctx context.Context, telegram *tgbotapi.BotAPI, cfg srvenv.Config) error

type Job

type Job struct {
	Kind JobKind
	Payload
}

type JobKind

type JobKind uint8
const (
	JobKindFetching JobKind = iota
	JobKindUploading
)

type MetadataDB

type MetadataDB interface {
	FetchByMetadata(ctx context.Context, videoID string, mime string, quality string) (db.Metadata, error)
	Save(ctx context.Context, model db.Metadata) error
}

type MockAMQPChannel

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

MockAMQPChannel is a mock of AMQPChannel interface.

func NewMockAMQPChannel

func NewMockAMQPChannel(ctrl *gomock.Controller) *MockAMQPChannel

NewMockAMQPChannel creates a new mock instance.

func (*MockAMQPChannel) Close

func (m *MockAMQPChannel) Close() error

Close mocks base method.

func (*MockAMQPChannel) Consume

func (m *MockAMQPChannel) Consume(queue, consumer string, autoAck, exclusive, noLocal, noWait bool, args amqp.Table) (<-chan amqp.Delivery, error)

Consume mocks base method.

func (*MockAMQPChannel) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockAMQPChannel) Publish

func (m *MockAMQPChannel) Publish(exchange, key string, mandatory, immediate bool, msg amqp.Publishing) error

Publish mocks base method.

func (*MockAMQPChannel) QueueDeclare

func (m *MockAMQPChannel) QueueDeclare(name string, durable, autoDelete, exclusive, noWait bool, args amqp.Table) (amqp.Queue, error)

QueueDeclare mocks base method.

type MockAMQPChannelMockRecorder

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

MockAMQPChannelMockRecorder is the mock recorder for MockAMQPChannel.

func (*MockAMQPChannelMockRecorder) Close

Close indicates an expected call of Close.

func (*MockAMQPChannelMockRecorder) Consume

func (mr *MockAMQPChannelMockRecorder) Consume(queue, consumer, autoAck, exclusive, noLocal, noWait, args interface{}) *gomock.Call

Consume indicates an expected call of Consume.

func (*MockAMQPChannelMockRecorder) Publish

func (mr *MockAMQPChannelMockRecorder) Publish(exchange, key, mandatory, immediate, msg interface{}) *gomock.Call

Publish indicates an expected call of Publish.

func (*MockAMQPChannelMockRecorder) QueueDeclare

func (mr *MockAMQPChannelMockRecorder) QueueDeclare(name, durable, autoDelete, exclusive, noWait, args interface{}) *gomock.Call

QueueDeclare indicates an expected call of QueueDeclare.

type MockAMQPConnection

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

MockAMQPConnection is a mock of AMQPConnection interface.

func NewMockAMQPConnection

func NewMockAMQPConnection(ctrl *gomock.Controller) *MockAMQPConnection

NewMockAMQPConnection creates a new mock instance.

func (*MockAMQPConnection) Chan

func (m *MockAMQPConnection) Chan() (AMQPChannel, error)

Chan mocks base method.

func (*MockAMQPConnection) Close

func (m *MockAMQPConnection) Close() error

Close mocks base method.

func (*MockAMQPConnection) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

type MockAMQPConnectionMockRecorder

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

MockAMQPConnectionMockRecorder is the mock recorder for MockAMQPConnection.

func (*MockAMQPConnectionMockRecorder) Chan

Chan indicates an expected call of Chan.

func (*MockAMQPConnectionMockRecorder) Close

Close indicates an expected call of Close.

type MockBlob

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

MockBlob is a mock of Blob interface.

func NewMockBlob

func NewMockBlob(ctrl *gomock.Controller) *MockBlob

NewMockBlob creates a new mock instance.

func (*MockBlob) CreateObject

func (m *MockBlob) CreateObject(ctx context.Context, bucket, key string, contents []byte) error

CreateObject mocks base method.

func (*MockBlob) DeleteObject

func (m *MockBlob) DeleteObject(ctx context.Context, bucket, key string) error

DeleteObject mocks base method.

func (*MockBlob) EXPECT

func (m *MockBlob) EXPECT() *MockBlobMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockBlob) GetObject

func (m *MockBlob) GetObject(ctx context.Context, bucket, key string) ([]byte, error)

GetObject mocks base method.

type MockBlobMockRecorder

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

MockBlobMockRecorder is the mock recorder for MockBlob.

func (*MockBlobMockRecorder) CreateObject

func (mr *MockBlobMockRecorder) CreateObject(ctx, bucket, key, contents interface{}) *gomock.Call

CreateObject indicates an expected call of CreateObject.

func (*MockBlobMockRecorder) DeleteObject

func (mr *MockBlobMockRecorder) DeleteObject(ctx, bucket, key interface{}) *gomock.Call

DeleteObject indicates an expected call of DeleteObject.

func (*MockBlobMockRecorder) GetObject

func (mr *MockBlobMockRecorder) GetObject(ctx, bucket, key interface{}) *gomock.Call

GetObject indicates an expected call of GetObject.

type MockMetadataDB

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

MockMetadataDB is a mock of MetadataDB interface.

func NewMockMetadataDB

func NewMockMetadataDB(ctrl *gomock.Controller) *MockMetadataDB

NewMockMetadataDB creates a new mock instance.

func (*MockMetadataDB) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockMetadataDB) FetchByMetadata

func (m *MockMetadataDB) FetchByMetadata(ctx context.Context, videoID, mime, quality string) (db.Metadata, error)

FetchByMetadata mocks base method.

func (*MockMetadataDB) Save

func (m *MockMetadataDB) Save(ctx context.Context, model db.Metadata) error

Save mocks base method.

type MockMetadataDBMockRecorder

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

MockMetadataDBMockRecorder is the mock recorder for MockMetadataDB.

func (*MockMetadataDBMockRecorder) FetchByMetadata

func (mr *MockMetadataDBMockRecorder) FetchByMetadata(ctx, videoID, mime, quality interface{}) *gomock.Call

FetchByMetadata indicates an expected call of FetchByMetadata.

func (*MockMetadataDBMockRecorder) Save

func (mr *MockMetadataDBMockRecorder) Save(ctx, model interface{}) *gomock.Call

Save indicates an expected call of Save.

type MockTelegramSender

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

MockTelegramSender is a mock of TelegramSender interface.

func NewMockTelegramSender

func NewMockTelegramSender(ctrl *gomock.Controller) *MockTelegramSender

NewMockTelegramSender creates a new mock instance.

func (*MockTelegramSender) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockTelegramSender) Send

Send mocks base method.

func (*MockTelegramSender) UploadFileWithContext

func (m *MockTelegramSender) UploadFileWithContext(ctx context.Context, endpoint string, params map[string]string, fieldname string, file interface{}) (telegram_bot_api.APIResponse, error)

UploadFileWithContext mocks base method.

type MockTelegramSenderMockRecorder

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

MockTelegramSenderMockRecorder is the mock recorder for MockTelegramSender.

func (*MockTelegramSenderMockRecorder) Send

func (mr *MockTelegramSenderMockRecorder) Send(c interface{}) *gomock.Call

Send indicates an expected call of Send.

func (*MockTelegramSenderMockRecorder) UploadFileWithContext

func (mr *MockTelegramSenderMockRecorder) UploadFileWithContext(ctx, endpoint, params, fieldname, file interface{}) *gomock.Call

UploadFileWithContext indicates an expected call of UploadFileWithContext.

type MockYoutubeClient

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

MockYoutubeClient is a mock of YoutubeClient interface.

func NewMockYoutubeClient

func NewMockYoutubeClient(ctrl *gomock.Controller) *MockYoutubeClient

NewMockYoutubeClient creates a new mock instance.

func (*MockYoutubeClient) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockYoutubeClient) GetStreamContext

func (m *MockYoutubeClient) GetStreamContext(ctx context.Context, video *v2.Video, format *v2.Format) (io.ReadCloser, int64, error)

GetStreamContext mocks base method.

func (*MockYoutubeClient) GetVideoContext

func (m *MockYoutubeClient) GetVideoContext(ctx context.Context, url string) (*v2.Video, error)

GetVideoContext mocks base method.

type MockYoutubeClientMockRecorder

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

MockYoutubeClientMockRecorder is the mock recorder for MockYoutubeClient.

func (*MockYoutubeClientMockRecorder) GetStreamContext

func (mr *MockYoutubeClientMockRecorder) GetStreamContext(ctx, video, format interface{}) *gomock.Call

GetStreamContext indicates an expected call of GetStreamContext.

func (*MockYoutubeClientMockRecorder) GetVideoContext

func (mr *MockYoutubeClientMockRecorder) GetVideoContext(ctx, url interface{}) *gomock.Call

GetVideoContext indicates an expected call of GetVideoContext.

type Option

type Option func(*Dispatcher)

type Options

type Options struct {
	Bucket                    string
	TelegramPollingTimeout    int
	TelegramUpdatesMaxWorkers int
	FetchingMaxWorker         int
	UploadingMaxWorker        int
}

type ParsingAction

type ParsingAction struct{}

func (*ParsingAction) Execute

func (p *ParsingAction) Execute(eventCtx botstate.EventContext) botstate.EventType

type ParsingCtx

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

type Payload

type Payload struct {
	Mime    string `json:"mime"`
	Quality string `json:"quality"`
	VideoID string `json:"video_id"`
	ChatID  int64  `json:"chat_id"`
}

type TelegramSender

type TelegramSender interface {
	Send(c tgbotapi.Chattable) (tgbotapi.Message, error)
	UploadFileWithContext(ctx context.Context, endpoint string, params map[string]string, fieldname string, file interface{}) (tgbotapi.APIResponse, error)
}

type YoutubeClient

type YoutubeClient interface {
	GetVideoContext(ctx context.Context, url string) (*youtube.Video, error)
	GetStreamContext(ctx context.Context, video *youtube.Video, format *youtube.Format) (io.ReadCloser, int64, error)
}

Jump to

Keyboard shortcuts

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