handlers

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BUILDING_BUTTON    = "building"
	NEXT_BUTTON        = "next"
	LANGUAGE_BUTTON    = "language"
	MAX_MESSAGE_LENGTH = 50
)
View Source
const (
	DEFAULT_DISTANCE = 100
)

Variables

View Source
var (
	ErrNoChat             = errors.New("a message contains no chat")
	ErrNoLocation         = errors.New("a message contains no location")
	ErrUnexpectedCallback = errors.New("a callback contains unexpected info")
)
View Source
var ErrNoFieldTag error = errors.New("no expected field tag")
View Source
var ErrNoNameTag error = errors.New("no name tag")
View Source
var ErrUnexpectedFieldType error = errors.New("unexpected field type")
View Source
var ErrUnexpectedType error = errors.New("unexpected input type")

Functions

func SerializeIntoMessage

func SerializeIntoMessage(object any, outputLanguage s.Language) (string, error)

Types

type BotWithMetrics added in v0.1.0

type BotWithMetrics struct {
	*tgbotapi.BotAPI
	// contains filtered or unexported fields
}

func NewBotWithMetrics added in v0.1.0

func NewBotWithMetrics(bot *tgbotapi.BotAPI, m *metrics.Metrics) *BotWithMetrics

func (*BotWithMetrics) Request added in v0.1.0

func (*BotWithMetrics) Send added in v0.1.0

type BuildingButton added in v1.0.0

type BuildingButton struct {
	Button
	ID string `json:"id"`
}

type Button

type Button struct {
	Name string `json:"name"`
	// contains filtered or unexported fields
}

type ButtonHandler

type ButtonHandler func(c.Context, *tgbotapi.CallbackQuery) error

type CommandHandler

type CommandHandler struct {
	Function    func(HandlerContainer, c.Context, *tgbotapi.Message) error
	Description string
}

type HandlerContainer

type HandlerContainer struct {
	HandlersPerCommand map[string]CommandHandler
	// contains filtered or unexported fields
}

func NewCommandContainer

func NewCommandContainer(
	bot InternalBot,
	service services.BuildingService,
	userService services.UserService,
	metricsContainer *metrics.Metrics,
) HandlerContainer

func (HandlerContainer) GetButtonHandler

func (h HandlerContainer) GetButtonHandler(buttonName string) (ButtonHandler, bool)

func (HandlerContainer) GetCommandHandler added in v0.1.0

func (h HandlerContainer) GetCommandHandler(command string) (func(c.Context, *tgbotapi.Message) error, bool)

func (HandlerContainer) ProcessCommonMessage added in v1.0.0

func (h HandlerContainer) ProcessCommonMessage(ctx c.Context, message *tgbotapi.Message) error

func (HandlerContainer) SendMessage

func (h HandlerContainer) SendMessage(ctx c.Context, chatId int64, msgText string, parseMode string) error

type InternalBot added in v0.1.0

type InternalBot interface {
	Request(tgbotapi.Chattable) (*tgbotapi.APIResponse, error)
	Send(tgbotapi.Chattable) (tgbotapi.Message, error)
	GetUpdatesChan(tgbotapi.UpdateConfig) tgbotapi.UpdatesChannel
}

type InternalBot_mock added in v0.1.0

type InternalBot_mock struct {
	mock.Mock
}

InternalBot_mock is an autogenerated mock type for the InternalBot type

func NewInternalBot_mock added in v0.1.0

func NewInternalBot_mock(t interface {
	mock.TestingT
	Cleanup(func())
}) *InternalBot_mock

NewInternalBot_mock creates a new instance of InternalBot_mock. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*InternalBot_mock) EXPECT added in v0.1.0

func (*InternalBot_mock) GetUpdatesChan added in v0.1.0

GetUpdatesChan provides a mock function with given fields: _a0

func (*InternalBot_mock) Request added in v0.1.0

Request provides a mock function with given fields: _a0

func (*InternalBot_mock) Send added in v0.1.0

Send provides a mock function with given fields: _a0

type InternalBot_mock_Expecter added in v0.1.0

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

func (*InternalBot_mock_Expecter) GetUpdatesChan added in v0.1.0

func (_e *InternalBot_mock_Expecter) GetUpdatesChan(_a0 interface{}) *InternalBot_mock_GetUpdatesChan_Call

GetUpdatesChan is a helper method to define mock.On call

  • _a0 tgbotapi.UpdateConfig

func (*InternalBot_mock_Expecter) Request added in v0.1.0

func (_e *InternalBot_mock_Expecter) Request(_a0 interface{}) *InternalBot_mock_Request_Call

Request is a helper method to define mock.On call

  • _a0 tgbotapi.Chattable

func (*InternalBot_mock_Expecter) Send added in v0.1.0

func (_e *InternalBot_mock_Expecter) Send(_a0 interface{}) *InternalBot_mock_Send_Call

Send is a helper method to define mock.On call

  • _a0 tgbotapi.Chattable

type InternalBot_mock_GetUpdatesChan_Call added in v0.1.0

type InternalBot_mock_GetUpdatesChan_Call struct {
	*mock.Call
}

InternalBot_mock_GetUpdatesChan_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetUpdatesChan'

func (*InternalBot_mock_GetUpdatesChan_Call) Return added in v0.1.0

func (*InternalBot_mock_GetUpdatesChan_Call) Run added in v0.1.0

func (*InternalBot_mock_GetUpdatesChan_Call) RunAndReturn added in v0.1.0

type InternalBot_mock_Request_Call added in v0.1.0

type InternalBot_mock_Request_Call struct {
	*mock.Call
}

InternalBot_mock_Request_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Request'

func (*InternalBot_mock_Request_Call) Return added in v0.1.0

func (*InternalBot_mock_Request_Call) Run added in v0.1.0

func (*InternalBot_mock_Request_Call) RunAndReturn added in v0.1.0

type InternalBot_mock_Send_Call added in v0.1.0

type InternalBot_mock_Send_Call struct {
	*mock.Call
}

InternalBot_mock_Send_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Send'

func (*InternalBot_mock_Send_Call) Return added in v0.1.0

func (*InternalBot_mock_Send_Call) Run added in v0.1.0

func (*InternalBot_mock_Send_Call) RunAndReturn added in v0.1.0

type LanguageButton added in v1.0.0

type LanguageButton struct {
	Button
	Language string `json:"value"`
}

type NextButton added in v1.0.0

type NextButton struct {
	Button
	Limit  int `json:"limit,omitempty"`
	Offset int `json:"offset,omitempty"`
}

Jump to

Keyboard shortcuts

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