bots

package module
v1.1.15 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Location *time.Location

Functions

func InitLog

func InitLog()

Types

type BaseHandler added in v1.0.4

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

func (*BaseHandler) GetBot added in v1.0.4

func (h *BaseHandler) GetBot() *telegram.Bot

func (*BaseHandler) OnShutdown added in v1.0.4

func (h *BaseHandler) OnShutdown() (err error)

func (*BaseHandler) OnUpdate added in v1.0.4

func (h *BaseHandler) OnUpdate(ctx context.Context, req *Request) (err error)

type CallbackData

type CallbackData struct {
	Command  CommandCode
	Flags    Flags
	Payload  []byte
	ReturnTo *CallbackData
	// contains filtered or unexported fields
}

func DecodeCallbackData added in v1.0.4

func DecodeCallbackData(payload string) (callbackData *CallbackData, err error)

func (*CallbackData) Confirmed added in v1.0.4

func (d *CallbackData) Confirmed() bool

func (*CallbackData) DecodePayload added in v1.0.4

func (d *CallbackData) DecodePayload(payload interface{}) (err error)

func (*CallbackData) EncodePayload added in v1.0.4

func (d *CallbackData) EncodePayload(payload interface{}) (err error)

func (*CallbackData) NewMessage added in v1.0.4

func (d *CallbackData) NewMessage() bool

func (*CallbackData) String

func (d *CallbackData) String() string

type CommandCode added in v1.0.4

type CommandCode uint8

type ErrorWithStatusCode

type ErrorWithStatusCode struct {
	StatusCode int
	Err        error
}

func (*ErrorWithStatusCode) Error

func (e *ErrorWithStatusCode) Error() string

type Flags added in v1.0.4

type Flags uint8
const (
	FlagNewMessage Flags = 1 << iota
	FlagConfirmed
)

type Frame added in v1.0.4

type Frame struct {
	Handler Handler
	BotUser *telegram.User
	// contains filtered or unexported fields
}

func (*Frame) Listen added in v1.0.4

func (f *Frame) Listen(ctx context.Context) (err error)

func (*Frame) Loop added in v1.0.4

func (f *Frame) Loop(ctx context.Context) (err error)

func (*Frame) OnInterrupt added in v1.0.4

func (f *Frame) OnInterrupt(cancel context.CancelFunc)

func (*Frame) Run added in v1.0.4

func (f *Frame) Run(ctx context.Context) (err error)

func (*Frame) Shutdown added in v1.0.4

func (f *Frame) Shutdown(cancel context.CancelFunc)

type Handler

type Handler interface {
	OnUpdate(context.Context, *Request) error
	OnShutdown() error
	GetBot() *telegram.Bot
}

type Request added in v1.0.4

type Request struct {
	BotUsername     string
	Command         string
	Payload         string
	ChatId          telegram.ChatId
	Chat            *telegram.Chat
	UserId          int64
	User            *telegram.User
	MessageId       int64
	Message         *telegram.Message
	CallbackQueryId string
	CallbackData    *CallbackData
}

func ParseCallbackQuery

func ParseCallbackQuery(callbackQuery *telegram.CallbackQuery) (req *Request, err error)

func ParseMessage

func ParseMessage(message *telegram.Message) (req *Request, err error)

func (*Request) Confirmed added in v1.0.4

func (req *Request) Confirmed() bool

func (*Request) GetCallbackDataPayload added in v1.0.4

func (req *Request) GetCallbackDataPayload() interface{}

func (*Request) HasContact added in v1.0.4

func (req *Request) HasContact() bool

func (*Request) IsCommand added in v1.0.4

func (req *Request) IsCommand(str string, code CommandCode) bool

func (*Request) NewMessage added in v1.0.4

func (req *Request) NewMessage() bool

type State

type State int
const (
	StateIdle State = iota
	StateRunning
	StateShutdown
)

type YandexRequest

type YandexRequest struct {
	Body string `json:"body"`
}

type YandexResponse

type YandexResponse struct {
	StatusCode int         `json:"statusCode"`
	Body       interface{} `json:"body"`
}

func YandexHandler

func YandexHandler(ctx context.Context, req *YandexRequest, h Handler) (res *YandexResponse, err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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