reporter

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2020 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Exporter

type Exporter struct {
	ExporterParams
	// contains filtered or unexported fields
}

Exporter performs conversion from log file to html

func NewExporter

func NewExporter(fileRecipient FileRecipient, storage Storage, params ExporterParams) *Exporter

NewExporter from params, initializes time.Location

func (*Exporter) Export

func (e *Exporter) Export(showNum int, yyyymmdd int) error

Export to html with showNum

type ExporterParams

type ExporterParams struct {
	OutputRoot     string
	InputRoot      string
	TemplateFile   string
	BotUsername    string
	SuperUsers     SuperUser
	BroadcastUsers SuperUser // Users who can send "bot.MsgBroadcastStarted" and "bot.MsgBroadcastStarted" messages.

}

ExporterParams for locations

type FileRecipient

type FileRecipient interface {
	GetFile(fileID string) (io.ReadCloser, error)
}

FileRecipient knows how to get file by fileID Needed mainly for tests to mock

func NewTelegramFileRecipient

func NewTelegramFileRecipient(botAPI *tbapi.BotAPI, timeout time.Duration) FileRecipient

NewTelegramFileRecipient creates TelegramFileRecipient

type Reporter

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

Reporter collects all messages and saves to plain file

func NewLogger

func NewLogger(logs string) (result Reporter)

NewLogger makes new reporter bot

func (Reporter) Save

func (l Reporter) Save(msg *bot.Message)

Save to log channel, non-blocking and skip if needed

type Storage

type Storage interface {
	FileExists(fileName string) (bool, error)
	CreateFile(fileName string, body []byte) (string, error)
	BuildLink(fileName string) string
	BuildPath(fileName string) string
}

Storage knows how to: create file, check for file existence and build a public-accessible link (relative in our case)

type SuperUser

type SuperUser interface {
	IsSuper(user string) bool
}

SuperUser knows which user is a superuser

type TelegramFileRecipient

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

TelegramFileRecipient implements FileRecipient for Telegram files

func (TelegramFileRecipient) GetFile

func (tfd TelegramFileRecipient) GetFile(fileID string) (io.ReadCloser, error)

GetFile gets file from Telegram

Jump to

Keyboard shortcuts

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