bot

package
v0.0.0-...-e0b26eb Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2023 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Build = "noBuildInfo" // go build -ldflags "-X github.com/michurin/cnbot/pkg/bot.Build=`date +%F`-`git rev-parse --short HEAD`" ./cmd/...
View Source
var Version = version

Functions

func BotsReport

func BotsReport(rootCtx context.Context, cfgs map[string]hps.BotConfig) string

func MessageProcessor

func MessageProcessor(ctx context.Context, msgQueue <-chan tg.Message, botMap map[string]hps.BotConfig)

func Poller

func Poller(baseCtx context.Context, botName string, bot hps.BotConfig, msgQueue chan<- tg.Message)

func Run

func Run(rootCtx context.Context)

TODO split Run to make it embeddable Run has to obtain: - shutdown context - configs - logger - http client - http server

func RunHTTPServer

func RunHTTPServer(ctx context.Context, addr string, writeTimeout time.Duration, readTimeout time.Duration, handler http.Handler)

func SmartSend

func SmartSend(
	ctx context.Context,
	token,
	callbackID string,
	destUser,
	callbackMessageID int64,
	stdout []byte,
	caption string,
) error

Types

type AliveHandler

type AliveHandler struct{}

func (*AliveHandler) ServeHTTP

func (h *AliveHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Handler

type Handler struct {
	BotName   string
	Token     string
	AccessCtl hps.AccessCtl
}

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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