bot

package
Version: v0.0.0-...-2afc11d Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MessageHelp = `` /* 340-byte string literal not displayed */

)
View Source
const MessageTopSlate = `` /* 1223-byte string literal not displayed */

As https://slatestarcodex.com top posts won't change anymore it's much more effecient to return hardcoded list.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bot

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

func New

func New(options ...Options) (*Bot, error)

func (*Bot) ChangeSource

func (b *Bot) ChangeSource(ctx context.Context, userID int, newSource models.Source) (string, interface{}, error)

func (*Bot) GetUpdatesChan

func (b *Bot) GetUpdatesChan() (tgbotapi.UpdatesChannel, error)

func (*Bot) MessageHandler

func (b *Bot) MessageHandler(ctx context.Context, update tgbotapi.Update) (tgbotapi.Message, error)

func (*Bot) RandomPost

func (b *Bot) RandomPost(ctx context.Context, userID int) (string, error)

func (*Bot) TopPosts

func (b *Bot) TopPosts(ctx context.Context, userID int) (string, error)

type DefaultHTTPClient

type DefaultHTTPClient struct {
	*http.Client
}

func NewHTTPClient

func NewHTTPClient() *DefaultHTTPClient

func (*DefaultHTTPClient) Get

func (c *DefaultHTTPClient) Get(ctx context.Context, url string) (*http.Response, error)

func (*DefaultHTTPClient) Post

func (c *DefaultHTTPClient) Post(ctx context.Context, url, contentType string, body io.Reader) (*http.Response, error)

type HTTPClient

type HTTPClient interface {
	Get(ctx context.Context, uri string) (*http.Response, error)
	Post(ctx context.Context, url, contentType string, body io.Reader) (*http.Response, error)
}

type Options

type Options struct {
	Config     config.Config
	BotAPI     *tgbotapi.BotAPI
	HTTPClient HTTPClient
	Storage    Storage
	RandomInt  func(n int) int
}

type Storage

type Storage interface {
	Get(ctx context.Context, key string) (string, error)
	Set(ctx context.Context, key, value string, expire time.Duration) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to