Documentation ¶
Index ¶
- Constants
- Variables
- func HandleFloat(m *tb.Message) (string, error)
- func HandleRaw(m *tb.Message) (string, error)
- func ParseAmount(f float64) string
- func ParseDate(m string) (string, error)
- func Recipient(m *tb.Message) tb.Recipient
- func ReplyKeyboard(buttons []string) *tb.ReplyMarkup
- type Bot
- func (b *Bot) Handle(endpoint interface{}, handler tb.HandlerFunc, m ...tb.MiddlewareFunc)
- func (b *Bot) Me() *tb.User
- func (b *Bot) Respond(c *tb.Callback, resp ...*tb.CallbackResponse) error
- func (b *Bot) Send(to tb.Recipient, what interface{}, options ...interface{}) (*tb.Message, error)
- func (b *Bot) Start()
- type BotController
- type CMD
- type Hint
- type HintTemplate
- type IBot
- type Input
- type NumberConfig
- type ReceiverImpl
- type Sender
- type SimpleTx
- func (tx *SimpleTx) CacheData() (data map[string]string)
- func (tx *SimpleTx) Debug() string
- func (tx *SimpleTx) EnrichHint(r *crud.Repo, m *tb.Message, i *Input) *Hint
- func (tx *SimpleTx) FillTemplate(currency, tag string, tzOffset int) (string, error)
- func (tx *SimpleTx) Input(m *tb.Message) (isDone bool, err error)
- func (tx *SimpleTx) IsDone() bool
- func (tx *SimpleTx) NextHint(r *crud.Repo, m *tb.Message) *Hint
- func (tx *SimpleTx) Prepare() Tx
- func (tx *SimpleTx) SetDate(d string) (Tx, error)
- type StateHandler
- func (s *StateHandler) Clear(m *tb.Message)
- func (s *StateHandler) CountOpen() int
- func (s *StateHandler) GetTx(m *tb.Message) Tx
- func (s *StateHandler) GetType(m *tb.Message) StateType
- func (s *StateHandler) SimpleTx(m *tb.Message, suggestedCur string) (Tx, error)
- func (s *StateHandler) StartTpl(m *tb.Message, name string)
- func (s *StateHandler) TemplateTx(m *tb.Message, template, suggestedCur, date string) (Tx, error)
- type StateType
- type TemplateField
- type TemplateHintData
- type TemplateName
- type TemplateTx
- type Tx
- type Type
Constants ¶
View Source
const ( CMD_START = "start" CMD_HELP = "help" CMD_CANCEL = "cancel" CMD_SIMPLE = "simple" CMD_LIST = "list" CMD_ARCHIVE_ALL = "archiveAll" CMD_DELETE_ALL = "deleteAll" CMD_SUGGEST = "suggestions" CMD_CONFIG = "config" CMD_ADM_NOTIFY = "admin_notify" CMD_ADM_CRON = "admin_cron" )
View Source
const ( TRACE = helpers.TRACE DEBUG = helpers.DEBUG INFO = helpers.INFO WARN = helpers.WARN ERROR = helpers.ERROR FATAL = helpers.FATAL )
View Source
const FORMATTER_PLACEHOLDER = "${SPACE_FORMAT}"
View Source
const MSG_UNFINISHED_STATE = "You have an unfinished operation running. Please finish it or /cancel it before starting a new one."
View Source
const TEMPLATE_SIMPLE_DEFAULT = `${date} * "${description}"${tag}
${account:from:the money came *from*} ${-amount}
${account:to:the money went *to*}`
Variables ¶
View Source
var ( CMD_COMMENT = []string{"comment", "c"} CMD_TEMPLATE = []string{"template", "t"} )
View Source
var TEMPLATE_TYPE_HINTS = map[Type]HintTemplate{ Type(c.FIELD_AMOUNT): { Text: "Please enter the *amount* of money {{.FieldHint}} (e.g. '12.34' or '12.34 {{.FieldDefault}}')", Handler: HandleFloat, }, Type(c.FIELD_ACCOUNT): { Text: "Please enter the *account* {{.FieldHint}} (or select one from the list)", Handler: HandleRaw, }, Type(c.FIELD_DESCRIPTION): { Text: "Please enter a *description* {{.FieldHint}} (or select one from the list)", Handler: HandleRaw, }, }
Functions ¶
func ParseAmount ¶
func ReplyKeyboard ¶
func ReplyKeyboard(buttons []string) *tb.ReplyMarkup
Types ¶
type Bot ¶
type Bot struct {
// contains filtered or unexported fields
}
func (*Bot) Handle ¶
func (b *Bot) Handle(endpoint interface{}, handler tb.HandlerFunc, m ...tb.MiddlewareFunc)
type BotController ¶
type BotController struct { Repo *crud.Repo State *StateHandler Bot IBot CronScheduler *gocron.Scheduler }
func NewBotController ¶
func NewBotController(db dbWrapper.DB) *BotController
func (*BotController) AddBotAndStart ¶
func (bc *BotController) AddBotAndStart(b IBot)
func (*BotController) ConfigureCronScheduler ¶
func (bc *BotController) ConfigureCronScheduler() *BotController
func (*BotController) MergeMessagesHonorSendLimit ¶ added in v0.17.1
func (bc *BotController) MergeMessagesHonorSendLimit(m []string, sep string) []string
type CMD ¶
type CMD struct { CommandAlias []string Optional []string Handler tb.HandlerFunc Help string }
type HintTemplate ¶ added in v0.21.0
type IBot ¶
type IBot interface { // Using from base package: Start() Handle(endpoint interface{}, h tb.HandlerFunc, m ...tb.MiddlewareFunc) Send(to tb.Recipient, what interface{}, options ...interface{}) (*tb.Message, error) Respond(c *tb.Callback, resp ...*tb.CallbackResponse) error // custom by me: Me() *tb.User }
func CreateBot ¶
func CreateBot(bc *BotController) IBot
type NumberConfig ¶ added in v0.21.0
type ReceiverImpl ¶
type ReceiverImpl struct {
// contains filtered or unexported fields
}
func (ReceiverImpl) Recipient ¶
func (r ReceiverImpl) Recipient() string
type SimpleTx ¶
type SimpleTx struct {
// contains filtered or unexported fields
}
func (*SimpleTx) EnrichHint ¶
func (*SimpleTx) FillTemplate ¶
type StateHandler ¶
type StateHandler struct {
// contains filtered or unexported fields
}
func NewStateHandler ¶
func NewStateHandler() *StateHandler
func (*StateHandler) Clear ¶
func (s *StateHandler) Clear(m *tb.Message)
func (*StateHandler) CountOpen ¶ added in v0.18.3
func (s *StateHandler) CountOpen() int
func (*StateHandler) TemplateTx ¶
type TemplateField ¶
type TemplateField struct { TemplateHintData NumberConfig }
func ParseTemplateField ¶
func ParseTemplateField(rawField, currencySuggestion string) *TemplateField
func ParseTemplateFields ¶
func ParseTemplateFields(template, currencySuggestion string) []*TemplateField
func SortTemplateFields ¶ added in v0.21.0
func SortTemplateFields(unsortedFields []*TemplateField) []*TemplateField
func (*TemplateField) FieldIdentifierForValue ¶ added in v0.21.0
func (tf *TemplateField) FieldIdentifierForValue() string
type TemplateHintData ¶ added in v0.21.0
type TemplateName ¶
type TemplateName string
type TemplateTx ¶
type TemplateTx struct { }
type Tx ¶
type Tx interface { Prepare() Tx Input(*tb.Message) (bool, error) IsDone() bool Debug() string NextHint(*crud.Repo, *tb.Message) *Hint EnrichHint(r *crud.Repo, m *tb.Message, i *Input) *Hint FillTemplate(currency, tag string, tzOffset int) (string, error) CacheData() map[string]string SetDate(string) (Tx, error) // contains filtered or unexported methods }
func CreateSimpleTx ¶
Click to show internal directories.
Click to hide internal directories.