telega

package
v0.0.0-...-1fbc8d5 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: BSD-2-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BackgroundFunction

type BackgroundFunction func(ctx context.Context, events chan<- ChattableCloser)

BackgroundFunction runs in a background in a goroutine and sends back events as those get created

type Bot

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

Bot is a highger-level wrapper over tgbotpi. Allow adding service handlers and periodic functions.

func (*Bot) AddBackgroundTask

func (b *Bot) AddBackgroundTask(fn BackgroundFunction)

func (*Bot) AddHandler

func (b *Bot) AddHandler(cmd string, handler CommandHandler)

AddHandler registers a new handler function against a command string.

func (*Bot) AddPeriodicTask

func (b *Bot) AddPeriodicTask(interval time.Duration, reportMessage string, fn TaskFunction)

AddPeriodicTask registers a periodic task. Param 'interval' should be an increment of 5 mins, or it will be aligned to the next 5 mins boundary.

func (*Bot) Init

func (b *Bot) Init(ctx context.Context, runtime string) error

Init initializes telegram bot.

func (Bot) Run

func (b Bot) Run() (string, error)

Run starts the bot till interrupted.

type ChattableCloser

type ChattableCloser interface {
	tgbotapi.Chattable
	io.Closer
	SetChatID(chatID int64)
}

ChattableCloser is a chattable message, which is closed after use.

type ChattableDocument

type ChattableDocument struct {
	tgbotapi.DocumentConfig
}

ChattableDocument is a simple chat video

func (ChattableDocument) Close

func (c ChattableDocument) Close() error

Close is a noop function

func (*ChattableDocument) SetChatID

func (c *ChattableDocument) SetChatID(chatID int64)

SetChatID

type ChattablePicture

type ChattablePicture struct {
	tgbotapi.PhotoConfig
}

ChattablePicture is a simple chat picture

func (ChattablePicture) Close

func (c ChattablePicture) Close() error

Close is a noop function

func (*ChattablePicture) SetChatID

func (c *ChattablePicture) SetChatID(chatID int64)

SetChatID

type ChattableText

type ChattableText struct {
	tgbotapi.MessageConfig
}

ChattableText is a simple chat message

func (ChattableText) Close

func (c ChattableText) Close() error

Close is a noop function

func (*ChattableText) SetChatID

func (c *ChattableText) SetChatID(chatID int64)

SetChatID

type ChattableVideo

type ChattableVideo struct {
	tgbotapi.VideoConfig
}

ChattableVideo is a simple chat video

func (ChattableVideo) Close

func (c ChattableVideo) Close() error

Close is a noop function

func (*ChattableVideo) SetChatID

func (c *ChattableVideo) SetChatID(chatID int64)

SetChatID

type CommandHandler

type CommandHandler func(ctx context.Context, cmd *tgbotapi.Message, bot *tgbotapi.BotAPI) (response ChattableCloser, err error)

CommandHandler is a function, which can handle a specific bot command

type TaskFunction

type TaskFunction func(ctx context.Context) string

TaskFunction is a function, which is executed by bot periodically

Jump to

Keyboard shortcuts

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