tg

package
v0.0.1-101123-7abf427 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMockBot

func NewMockBot() (MockBot, MockBotClient)

func NewReplyf

func NewReplyf(to tgbotapi.Message, template string, args ...any) tgbotapi.MessageConfig

Types

type Bot

type Bot interface {
	Updates() tgbotapi.UpdatesChannel
	Send(m tgbotapi.Chattable) (tgbotapi.Message, error)
	Stop()
}

func NewBot

func NewBot(ctx context.Context, cfg Config, devel bool) (Bot, error)

type Config

type Config struct {
	TokenFile string `yaml:"token_file" validate:"required,file"`

	// TODO: add webhook option
	Poll *struct {
		Timeout time.Duration `yaml:"timeout"`
	} `yaml:"poll" validate:"required"`
}

func (*Config) SetDefaults

func (c *Config) SetDefaults()

type MockBot

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

func (MockBot) Send

func (MockBot) Stop

func (b MockBot) Stop()

func (MockBot) Updates

func (b MockBot) Updates() tgbotapi.UpdatesChannel

type MockBotClient

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

func (MockBotClient) Recv

func (MockBotClient) RecvMessage

func (c MockBotClient) RecvMessage(ctx context.Context, t *testing.T) tgbotapi.MessageConfig

func (MockBotClient) RequireEmpty

func (c MockBotClient) RequireEmpty(t *testing.T)

func (MockBotClient) SendMessage

func (c MockBotClient) SendMessage(ctx context.Context, t *testing.T, msg tgbotapi.Message)

func (MockBotClient) SendUpdate

func (c MockBotClient) SendUpdate(ctx context.Context, t *testing.T, u tgbotapi.Update)

Jump to

Keyboard shortcuts

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