tg

package
v0.0.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMessagef added in v0.0.2

func NewMessagef(chatID int64, format string, a ...any) tgbotapi.MessageConfig

func NewMockBot

func NewMockBot() (MockBot, MockBotClient)

func NewReplyf

func NewReplyf(to tgbotapi.Message, format string, a ...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