tgfun

package module
v1.7.5 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: MPL-2.0 Imports: 8 Imported by: 0

README

tgfun

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BuildMessageCallback added in v1.3.0

type BuildMessageCallback func(tb.Context) interface{}

type EventMessage

type EventMessage struct {
	// main data
	Text string `json:"text"`

	// instead of main data
	Callback BuildMessageCallback `json:"-"` // use it to redefine message

	// additional events
	OnEvent OnEventCallback `json:"-"`

	// optional
	Image            string               `json:"image"` // local filename or URL
	File             FileData             `json:"file"`
	Video            VideoData            `json:"video"`
	Buttons          []MessageButton      `json:"buttons"`
	Format           ParseFormat          `json:"format"`
	ButtonsIsColumns bool                 `json:"buttonsIsColumns"`
	Conversion       string               `json:"conversion"`
	OnConversion     OnConversionCallback `json:"-"`
	PinThisMessage   bool                 `json:"pin"`
}

EventMessage - funnel event message data

type FileData added in v1.7.2

type FileData struct {
	Path             string `json:"path"`
	Name             string `json:"name"`
	PreviewImagePath string `json:"preview"`
}

type Funnel

type Funnel struct {
	// public
	Data   FunnelData
	Script FunnelScript
	// contains filtered or unexported fields
}

Funnel - telegram bot funnel

func NewFunnel

func NewFunnel(data FunnelData, script FunnelScript) *Funnel

NewFunnel - funnel constructor

func (*Funnel) EnableUsersFeature added in v1.0.9

func (f *Funnel) EnableUsersFeature(feature UsersFeature)

EnableUsersFeature !

func (*Funnel) GetEventQueryHandler added in v1.6.0

func (f *Funnel) GetEventQueryHandler(
	eventMessageID string,
) (*QueryHandler, error)

func (*Funnel) Run

func (f *Funnel) Run() error

Run funnel. This is a non-blocking operation

type FunnelData

type FunnelData struct {
	Token     string `json:"token"`
	ImageRoot string `json:"imageRoot"`
}

FunnelData - data container for Funnel struct

type FunnelEvent

type FunnelEvent struct {
	Message EventMessage `json:"message"`
}

FunnelEvent - user interaction event

type FunnelScript

type FunnelScript map[string]FunnelEvent // message ID -> event

FunnelScript - funnel scenario

type MessageButton

type MessageButton struct {
	Text          string `json:"text"`
	NextMessageID string `json:"nextID"` // optional for URL-buttons
	URL           string `json:"url"`    // optional. only for URL-buttons
}

MessageButton - funnel event message button

type MessageType added in v1.7.5

type MessageType string
const (
	MessageTypeText     MessageType = "text"
	MessageTypePhoto    MessageType = "photo"
	MessageTypeDocument MessageType = "document"
	MessageTypeVideo    MessageType = "video"
)

type OnConversionCallback added in v1.6.2

type OnConversionCallback func(ctx tb.Context, conversionTag string) error

type OnEventCallback added in v1.3.0

type OnEventCallback func(tb.Context) error

type ParseFormat added in v1.6.3

type ParseFormat string
const (
	ParseFormatMarkdown ParseFormat = ParseFormat(tb.ModeMarkdown)
	ParseFormatHTML     ParseFormat = ParseFormat(tb.ModeHTML)
)

type QueryHandler added in v1.6.0

type QueryHandler struct {
	EventMessageID string
	EventData      FunnelEvent
	Menu           *tb.ReplyMarkup
	ParseMode      tb.ParseMode
	Bot            *tb.Bot
	FilesRoot      string // inherit from Funnel
	Features       *funnelFeatures
}

telegram user query handler

func (*QueryHandler) CustomHandle added in v1.6.0

func (q *QueryHandler) CustomHandle(telegramUserID int64) error

type UsersFeature added in v1.0.9

type UsersFeature struct {
	// required
	DBConn    *sql.DB
	TableName string

	// optional
	AdminChatID int64
}

UsersFeature - feature to enable users db

type VideoData added in v1.7.5

type VideoData struct {
	Path string `json:"path"`
}

Directories

Path Synopsis
lib module

Jump to

Keyboard shortcuts

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