handlers

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoCallbackMessage = errors.New("callback data doesn't have message id")
View Source
var ErrPrecheckoutQueryEmpty = errors.New("precheckout query is empty")

Functions

func ChatID

func ChatID(upd *telegram.Update) types.ChatID

func NewCallbackFilterFromSpec

func NewCallbackFilterFromSpec(s *spec.CallbackTrigger) (types.EventFilter, error)

func NewContextFilter

func NewContextFilter(base types.EventFilter, cp types.ContextProvider, val string) types.EventFilter

func NewMessageFilterFromSpec

func NewMessageFilterFromSpec(s *spec.MessageTrigger) (types.EventFilter, error)

Types

type CallbackFilter

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

CallbackFilter check update callback data.

func (*CallbackFilter) Check

func (h *CallbackFilter) Check(ctx context.Context, update *telegram.Update) (bool, error)

type CallbackReply

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

CallbackReply send callback message reply.

func NewCallbackReply

func NewCallbackReply(text string, alert bool) *CallbackReply

NewCallbackReply creates new callback reply handler.

func (*CallbackReply) Handle

func (h *CallbackReply) Handle(ctx context.Context, update *telegram.Update,
	bot *telegram.BotAPI) error

type ContextFilter

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

func (*ContextFilter) Check

func (h *ContextFilter) Check(ctx context.Context, update *telegram.Update) (bool, error)

type DeleteContextHandler

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

func NewContextDeleter

func NewContextDeleter(cp types.ContextProvider, val string, log zerolog.Logger) *DeleteContextHandler

func (*DeleteContextHandler) Handle

type InlineButton

type InlineButton struct {
	Text     string
	URL      string
	Callback string
}

type InlineKeyboard added in v1.1.0

type InlineKeyboard [][]InlineButton

type InvoiceConfig added in v1.2.0

type InvoiceConfig struct {
	Title       string
	Description string
	Payload     string
	Currency    string
	Prices      []InvoicePrice
}

type InvoicePrice added in v1.2.0

type InvoicePrice struct {
	Label  string
	Amount int
}

type MessageDelete added in v1.1.0

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

func NewMessageDelete added in v1.1.0

func NewMessageDelete(logger zerolog.Logger) *MessageDelete

func (*MessageDelete) Handle added in v1.1.0

func (d *MessageDelete) Handle(ctx context.Context, upd *telegram.Update, api *telegram.BotAPI) error

type MessageEdit added in v1.1.0

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

func NewMessageEdit added in v1.1.0

func NewMessageEdit(caption string, text string, keyboard InlineKeyboard,
	sp types.StateProvider, secrets types.Secrets, logger zerolog.Logger,
) *MessageEdit

func (*MessageEdit) Handle added in v1.1.0

func (h *MessageEdit) Handle(ctx context.Context, upd *telegram.Update, api *telegram.BotAPI) error

type MessageFilter

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

MessageFilter checks update by message criteria.

func (*MessageFilter) Check

func (h *MessageFilter) Check(ctx context.Context, update *telegram.Update) (bool, error)

type MessageModifier

type MessageModifier func(*telegram.MessageConfig)

MessageModifier apply custom modifications to telegram message reply.

func MessageWithInlineKeyboard added in v1.1.0

func MessageWithInlineKeyboard(keyboard InlineKeyboard) MessageModifier

MessageWithInlineKeyboard creates new message modifier to add custom inline keyboard to message.

func MessageWithKeyboard

func MessageWithKeyboard(keyboard [][]string) MessageModifier

MessageWithKeyboard creates new message modifier to add custom keyboard to message.

func MessageWithParseMode

func MessageWithParseMode(mode string) MessageModifier

MessageWithParseMode creates new message modifier to set custom parse mode for message.

type MessageReply

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

MessageReply handler processes telegram updates and reply message to them.

func NewMessageReply

func NewMessageReply(sp types.StateProvider, secrets types.Secrets,
	text string, logger zerolog.Logger, modifiers ...MessageModifier,
) *MessageReply

NewMessageReply from repliers funcs.

func (*MessageReply) Handle

func (h *MessageReply) Handle(ctx context.Context, upd *telegram.Update,
	bot *telegram.BotAPI,
) error

type PreCheckout added in v1.2.0

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

func NewPreCheckout added in v1.2.0

func NewPreCheckout(ok bool, err string, logger zerolog.Logger) *PreCheckout

func (*PreCheckout) Handle added in v1.2.0

func (h *PreCheckout) Handle(ctx context.Context, upd *telegram.Update, api *telegram.BotAPI) error

type ReplyDocument added in v1.3.0

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

ReplyDocument sends document file to chat.

func NewReplyDocument added in v1.3.0

func NewReplyDocument(key, name string, assets types.Assets,
	logger zerolog.Logger,
) *ReplyDocument

NewReplyDocument creates new ReplyDocument handler using file by key.

func (*ReplyDocument) Handle added in v1.3.0

func (h *ReplyDocument) Handle(ctx context.Context, upd *telegram.Update,
	api *telegram.BotAPI,
) error

type ReplyImage added in v1.1.0

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

ReplyImage sends image to chat.

func NewReplyImageFile added in v1.1.0

func NewReplyImageFile(key, name string, assets types.Assets,
	logger zerolog.Logger) *ReplyImage

NewReplyImageFile creates new ReplyImage handler using image from key.

func (*ReplyImage) Handle added in v1.1.0

func (h *ReplyImage) Handle(ctx context.Context, upd *telegram.Update,
	api *telegram.BotAPI) error

type SendInvoice added in v1.2.0

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

func NewSendInvoice added in v1.2.0

func NewSendInvoice(providers types.PaymentProviders, providerName string, config InvoiceConfig,
	logger zerolog.Logger) *SendInvoice

func (*SendInvoice) Handle added in v1.2.0

func (h *SendInvoice) Handle(ctx context.Context, upd *telegram.Update, api *telegram.BotAPI) error

type SetContextHandler

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

func NewContextSetter

func NewContextSetter(cp types.ContextProvider, value string, log zerolog.Logger) *SetContextHandler

func (*SetContextHandler) Handle

func (h *SetContextHandler) Handle(ctx context.Context, upd *telegram.Update, api *telegram.BotAPI) error

type StateHandler

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

func NewStateHandlerFromSpec

func NewStateHandlerFromSpec(provider types.StateProvider, spec *spec.State, log zerolog.Logger) *StateHandler

func (*StateHandler) Handle

func (h *StateHandler) Handle(ctx context.Context, update *telegram.Update, _ *telegram.BotAPI) error

type Webhook

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

func NewWebhook

func NewWebhook(url *url.URL, method string, data map[string]string, sp types.StateProvider,
	secrets types.Secrets, log zerolog.Logger,
) *Webhook

func (*Webhook) Handle

func (h *Webhook) Handle(ctx context.Context, upd *telegram.Update, _ *telegram.BotAPI) error

type WebhookPayload added in v1.3.0

type WebhookPayload struct {
	Data map[string]string `json:"data"`
	Meta struct {
		ChatID    int64     `json:"chat_id"`
		Timestamp time.Time `json:"timestamp"`
	} `json:"meta"`
}

Jump to

Keyboard shortcuts

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