core

package
v0.0.0-...-b351349 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2023 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Butlertron

type Butlertron struct {
	Bot      *telebot.Bot
	Config   Config
	Location *telebot.Location
	// contains filtered or unexported fields
}

func NewButlertron

func NewButlertron() (*Butlertron, error)

func (*Butlertron) CancelOnText

func (b *Butlertron) CancelOnText()

CancelOnText cancels the current command assigned to OnText If there is no OnText handler, it has been cancelled, or it has timed out, it is a noop

func (*Butlertron) RegisterInlineKeyboard

func (b *Butlertron) RegisterInlineKeyboard(commands [][]InlineCommand) *telebot.ReplyMarkup

func (*Butlertron) SetOnText

func (b *Butlertron) SetOnText(h telebot.HandlerFunc, timeout time.Duration, cancelAfterHandling bool)

SetOnText will set the command that will run when text is next sent If the deadline is exceed or it has been cancelled, there will be no reply

func (*Butlertron) SetOnTextDefault

func (b *Butlertron) SetOnTextDefault(h telebot.HandlerFunc)

SetOnTextDefault sets the default responder if no OnText has been manually trigger

type Command

type Command interface {
	Name() string
	// Description returns a brief description of the command.
	Description() string
	// Command is the string which will call the command
	Command() string
	// Execute is called when the command is triggered.
	Execute(c telebot.Context) error
}

Command is the interface that all bot commands must implement.

type Config

type Config struct {
	TelegramBotToken string `env:"TELEGRAM_BOT_TOKEN,required"`
	WeatherToken     string `env:"WEATHER_TOKEN,required"`
	OpenAIToken      string `env:"OPENAI_TOKEN,required"`
	StreamingToken   string `env:"STREAMING_TOKEN,required"`
}

type InlineCommand

type InlineCommand struct {
	// Name of the Inline Command
	Name string
	// Description of the Inline Command, this will be displayed on the button
	Description string
	// The Selector that stores this command
	Selector *telebot.ReplyMarkup
	// The Handler which is executed
	Handler telebot.HandlerFunc
	// The Parent Command. The inline command buttons will be displayed below this
	Parent Command
	// Conditional refers to if it should be loaded by default as a button. If true, it will not be added on init
	Conditional bool
}

type Location

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

func NewLocation

func NewLocation(b *Butlertron) *Location

func (Location) Command

func (w Location) Command() string

func (Location) Description

func (w Location) Description() string

func (*Location) Execute

func (w *Location) Execute(c telebot.Context) error

func (*Location) LocationMiddleware

func (l *Location) LocationMiddleware(next telebot.HandlerFunc) telebot.HandlerFunc

func (Location) Name

func (w Location) Name() string

Jump to

Keyboard shortcuts

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