accounting_bot

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 8, 2021 License: MIT Imports: 12 Imported by: 0

README

Accounting Telegram bot

Usage

Copy docker-compose.dist.yml to docker-compose.yml, edit as You want and say docker-compose up -d.

Configuration

  • LOG_LEVEL one of debug, info (default), warning, error
  • DATABASE_URL in format postgres://user:pass@host:5432/database?sslmode=disable
  • TELEGRAM_BOT_TOKEN telegram bot token
  • AUTH_CODE (optional) some password to keep bot private

License

MIT

Documentation

Index

Constants

View Source
const VERSION = 1

Variables

This section is empty.

Functions

func NewLogger

func NewLogger(level logrus.Level, namespace string) *logrus.Logger

Types

type AddTagCommand

type AddTagCommand struct {
	SearchTag string
	Tags      []string
}

type Bot

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

func New

func New(token string, logger *logrus.Logger, storage Storage, config Config) (*Bot, error)

func (*Bot) Start

func (b *Bot) Start() error

func (*Bot) Stop

func (b *Bot) Stop() error

type Command

type Command interface{}

func ParseCommand

func ParseCommand(message *tgbotapi.Message) (Command, error)

type Config

type Config struct {
	AuthCode     string
	AdminContact string
}

type CurrencyCommand

type CurrencyCommand struct {
	Currency string
}

type DumpCommand

type DumpCommand struct {
	From   time.Time
	Format string
	Tags   []string
}

type Entry

type Entry struct {
	ID        string
	Comment   string
	Tags      []string
	Currency  string
	Value     float32
	MessageID int64
	ReplyID   int64 // bot reply message id
}

type EntryCommand

type EntryCommand struct {
	Entry Entry
}

type Features

type Features struct{}

func (*Features) Scan

func (f *Features) Scan(data interface{}) error

func (Features) Value

func (f Features) Value() (driver.Value, error)

type HelpCommand

type HelpCommand struct{}

type InternalError

type InternalError struct {
	Err error
}

func NewInternalError

func NewInternalError(e error) *InternalError

func (InternalError) Error

func (e InternalError) Error() string

func (InternalError) String

func (InternalError) String() string

type InvalidAuthCodeError

type InvalidAuthCodeError struct {
}

func (InvalidAuthCodeError) Error

func (e InvalidAuthCodeError) Error() string

func (InvalidAuthCodeError) String

func (e InvalidAuthCodeError) String() string

type InvalidCurrencyError

type InvalidCurrencyError struct {
	Currency string
}

func (InvalidCurrencyError) Error

func (e InvalidCurrencyError) Error() string

func (InvalidCurrencyError) String

func (e InvalidCurrencyError) String() string

type InvalidSyntaxError

type InvalidSyntaxError struct {
}

func (InvalidSyntaxError) Error

func (e InvalidSyntaxError) Error() string

func (InvalidSyntaxError) String

func (e InvalidSyntaxError) String() string

type ListTagsCommand

type ListTagsCommand struct {
	SearchTags []string
}

type NamespaceHook

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

func NewNamespaceHook

func NewNamespaceHook(ns string) *NamespaceHook

func (*NamespaceHook) Fire

func (h *NamespaceHook) Fire(e *logrus.Entry) error

func (*NamespaceHook) Levels

func (h *NamespaceHook) Levels() []logrus.Level

type RemoveTagCommand

type RemoveTagCommand struct {
	Tags []string
}

type StartCommand

type StartCommand struct {
	Code string
}

type StatCommand

type StatCommand struct {
	From time.Time
	Tags []string
}

type Storage

type Storage interface {
	SaveUser(ctx context.Context, user *User) (*User, error)
	GetUserByTelegramID(ctx context.Context, id int64) (*User, error)
	SaveEntry(ctx context.Context, user *User, command *Entry) (*Entry, error)
	SaveReplyID(ctx context.Context, user *User, message, reply int64) error
	IterEntries(ctx context.Context, user *User, from time.Time, tags []string) (<-chan *Entry, error)
	AddTag(ctx context.Context, user *User, search string, tags []string) error
	RemoveTag(ctx context.Context, user *User, tags []string) error
	ListTag(ctx context.Context, user *User, search []string) ([]string, error)
}

type UnknownCommandError

type UnknownCommandError struct {
	Command string
}

func (UnknownCommandError) Error

func (e UnknownCommandError) Error() string

func (UnknownCommandError) String

func (e UnknownCommandError) String() string

type User

type User struct {
	ID         string
	TelegramID int64
	BotVersion int
	Enabled    bool
	Currency   string
	Features   Features
}

User struct using for save user settings, version and possible multiple chat providers support

type UserNotFoundError

type UserNotFoundError struct{}

func (UserNotFoundError) Error

func (e UserNotFoundError) Error() string

func (UserNotFoundError) String

func (UserNotFoundError) String() string

Directories

Path Synopsis
storage

Jump to

Keyboard shortcuts

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