bot

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2021 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bot

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

Bot implement transmission telegram bot.

func New

func New(tg Telegram, transmission Transmission, opts ...Option) *Bot

New returns new instance of the Bot with the given token that talks to Transmission client using transmission.

func (*Bot) Run

func (b *Bot) Run(ctx context.Context)

Run runs the bot until ctx is cancelled.

type Location

type Location struct {
	Name string
	Path string
}

Location is a named location for torrent contents.

type Logger

type Logger interface {
	Infof(fmt string, args ...interface{})
	Debugf(fmt string, args ...interface{})
}

Logger defines a logger interface accepted by the bot.

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option customized bot with optional configuration.

func WithAllowedUsers added in v0.2.0

func WithAllowedUsers(users ...string) Option

WithAllowedUser sets a username of the telegram account that is allowed to control the bot.

func WithHTTPClient

func WithHTTPClient(client *http.Client) Option

WithHTTPClient sets an HTTP client for the bot.

func WithLocations

func WithLocations(l ...Location) Option

WithLocations adds new torrent contents locations.

func WithLogger

func WithLogger(l Logger) Option

WithLogger configures the bot to use l for logging.

func WithSetCommands

func WithSetCommands() Option

WithSetCommands tells the bot to upload up-to-date list of the supported commands to the Telegram servers. It's not considered to be a fatal error if the upload fails. Alternitevly, this can be done manually via @BotFather.

type Telegram

type Telegram interface {
	MakeRequest(string, url.Values) (tgbotapi.APIResponse, error)
	GetUpdates(tgbotapi.UpdateConfig) ([]tgbotapi.Update, error)
	Send(tgbotapi.Chattable) (tgbotapi.Message, error)
	GetFileDirectURL(string) (string, error)
	AnswerCallbackQuery(tgbotapi.CallbackConfig) (tgbotapi.APIResponse, error)
}

Telegram defines an interface that telegram client must implement in order to be usable by this bot.

type Transmission

Transmission defines an interface that transmission client must implement in order to be usable by this bot.

Jump to

Keyboard shortcuts

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