Documentation
¶
Index ¶
- Constants
- func ByteToBool(b []byte) bool
- func ByteToInt8(b []byte) int8
- func ConfigInt(fromConfig int, mininalValue int, defaultValue int) int
- func ConfigString(configValue string, defaultValue string) string
- func Log2stdlib(l2 *log2.Log) *log.Logger
- func NormalizeWebPath(raw string) string
- type Client
- type Config
- func (c *Config) ParseWebURL() (origin, routePrefix string)
- func (c *Config) ScaleA(a currency.Amount) currency.Amount
- func (c *Config) ScaleI(i int) currency.Amount
- func (c *Config) ScaleU(u uint32) currency.Amount
- func (c *Config) WebAuthCallbackURL(token string) string
- func (c *Config) WebCookiePath() string
- func (c *Config) WebPathWithPrefix(rel string) string
- func (c *Config) WebRootPath() string
- func (c *Config) WebRoutePrefix() string
- type ConfigSource
- type FullReader
- type Global
- func (g *Global) AdminReplayAutoAction(mesage *string, userId int64, userType vender_api.OwnerType)
- func (g *Global) ClientChangeDefaultRobot(clientId int64, vmid int) error
- func (g *Global) ClientGet(clientId int64, clientType vender_api.OwnerType) (cl Client, err error)
- func (g *Global) ClientSetCredit(clientId int64, clientType vender_api.OwnerType, credit int)
- func (g *Global) ClientUpdateBalance(clientId int64, clientType vender_api.OwnerType, change int64)
- func (g *Global) CreateWebAuthToken(userId int64, userType int) (string, error)
- func (g *Global) Error(err error, args ...interface{})
- func (g *Global) GetDrinkName(vmid int32, code string) string
- func (g *Global) GetRoboState(vmid int32) vender_api.State
- func (g *Global) InitDB(cmdName string) error
- func (g *Global) InitVMC()
- func (g *Global) ItsWaitPayment(p tele_api.Packet) (bool, *tele.Response)
- func (g *Global) LogUserOrder(prefix string, userId int64, userType int32, action string, balanceInfo int64)
- func (g *Global) ParseFromRobo(p tele_api.Packet) *tele.FromRoboMessage
- func (g *Global) ParseMqttPacket(p tele_api.Packet) *tele.Response
- func (g *Global) ReadRoboStateFromDB(vmid int32) vender_api.State
- func (g *Global) RobotConnected(vmid int32) bool
- func (g *Global) SetRoboState(vmid int32, st vender_api.State)
- func (g *Global) Sha256sum(s string) string
- func (g *Global) VMCErrorWriteDb(vmid int32, message string, level ...int)
- func (g *Global) СheckRobotMakeState(vmid int32) (valid bool, messageImpossible string)
- type MockFullReader
- type OsFullReader
Constants ¶
const ContextKey = "run/state-global"
Variables ¶
This section is empty.
Functions ¶
func ByteToBool ¶
func ByteToInt8 ¶
func ConfigInt ¶ added in v0.241202.0
the value in the configuration should not be less than the minimal value значение в конфигурации не должно быть меньше минимального значения
func ConfigString ¶ added in v0.241202.0
if the value is not set in the configuration, then return the default value если значение в конфигурации не установлено, тогда возвращаем значение по умолчанию
func Log2stdlib ¶
TODO func (*log2.Log) Stdlib() *log.Logger
func NormalizeWebPath ¶ added in v0.260317.0
Types ¶
type Config ¶
type Config struct {
// only used for Unmarshal, do not access
XXX_Include []ConfigSource `hcl:"include"`
DB struct {
URL string `hcl:"url"`
PingTimeoutMs int `hcl:"ping_timeout_ms"`
}
Money struct {
Scale int `hcl:"scale"`
}
Tax struct {
Ru2019 struct {
Tag1009 string // payment address
Tag1187 string // payment place
Tag1018 string // business INN
Tag1055 int // uint32 tax form
Tag1199 int // uint32 tax rate
Umka struct {
BaseURL string `hcl:"base_url"`
XXX_testRT http.RoundTripper `hcl:"-"`
}
}
DebugLevel int `hcl:"debug_level"`
}
CashLess struct {
TerminalKey string
TerminalPass string
URLToListenToBankNotifications string // URL for incoming notifications. ссылка для банки, куда слать уведомления.
DebugLevel int
QRValidTimeSec int // order validation time. время валидности заказа
TerminalQRPayRefreshSec int // interval manualy cheking payment status. как часто опрашивать статус оплаты. во время валидного времени заказа
TerminalBankCommission int // bank commision. ( 1 = 0.01% ) комиссия бынка в сотых процента/
TerminalMinimalAmount int // minimal order amount. минимальная суммв заказа в копейках
TimeoutToStartManualPaymentVerificationSec int // after how many seconds to start checking the payment status manually. через сколько секунд начать проверять статус оплаты вручную
}
Telegram struct {
TelegrammBotApi string `hcl:"telegram_bot_api"`
AdminBot string `hcl:"admin_bot_name"`
Proxy string `hcl:"proxy"`
TelegramAdmin int64 `hcl:"telegram_admin"`
DebugMessages bool `hcl:"telegram_debug"`
}
Web struct {
BaseURL string `hcl:"web_url"`
SecretKey string `hcl:"secret_key"` // openssl rand -hex 32
// generate keys
// npx web-push generate-vapid-keys
VAPIDPublicKey string `hcl:"vapid_public_key"`
VAPIDPrivateKey string `hcl:"vapid_private_key"`
VAPIDSubject string `hcl:"vapid_subject"` //"mailto:admin@yourdomain.com"
}
Tele tele_config.Config
// contains filtered or unexported fields
}
func MustReadConfig ¶
func MustReadConfig(log *log2.Log, fs FullReader, names ...string) *Config
func ReadConfig ¶
func (*Config) ParseWebURL ¶ added in v0.260317.0
parseWebURL разбирает web_url на origin и path. "https://am.inkcat.net/robot" → origin="https://am.inkcat.net", routePrefix="/robot"
func (*Config) WebAuthCallbackURL ¶ added in v0.260317.0
func (*Config) WebCookiePath ¶ added in v0.260317.0
func (*Config) WebPathWithPrefix ¶ added in v0.260317.0
func (*Config) WebRootPath ¶ added in v0.260317.0
func (*Config) WebRoutePrefix ¶ added in v0.260317.0
type ConfigSource ¶
type FullReader ¶
type Global ¶
type Global struct {
Alive *alive.Alive
BuildVersion string
Config *Config
DB *pg.DB
Log *log2.Log
Tele tele_api.Teler
Vmc map[int32]*vmcStruct
}
func (*Global) AdminReplayAutoAction ¶ added in v0.260317.0
func (g *Global) AdminReplayAutoAction(mesage *string, userId int64, userType vender_api.OwnerType)
func (*Global) ClientChangeDefaultRobot ¶ added in v0.260317.0
func (*Global) ClientSetCredit ¶ added in v0.260317.0
func (g *Global) ClientSetCredit(clientId int64, clientType vender_api.OwnerType, credit int)
func (*Global) ClientUpdateBalance ¶ added in v0.260317.0
func (g *Global) ClientUpdateBalance(clientId int64, clientType vender_api.OwnerType, change int64)
func (*Global) CreateWebAuthToken ¶ added in v0.260317.0
func (*Global) GetDrinkName ¶ added in v0.260317.0
func (*Global) GetRoboState ¶
func (g *Global) GetRoboState(vmid int32) vender_api.State
func (*Global) ItsWaitPayment ¶
func (*Global) LogUserOrder ¶ added in v0.260317.0
func (*Global) ParseFromRobo ¶
func (g *Global) ParseFromRobo(p tele_api.Packet) *tele.FromRoboMessage
фиксирует подсоединение робота или парсит пакет на команду. fixes the connection of the robot or parses the packet on the command.
func (*Global) ParseMqttPacket ¶
OLD фиксирует подсоединение робота или парсит пакет на команду. fixes the connection of the robot or parses the packet on the command.
func (*Global) ReadRoboStateFromDB ¶ added in v0.241024.0
func (g *Global) ReadRoboStateFromDB(vmid int32) vender_api.State
func (*Global) RobotConnected ¶
func (*Global) SetRoboState ¶
func (g *Global) SetRoboState(vmid int32, st vender_api.State)
func (*Global) VMCErrorWriteDb ¶ added in v0.241202.0
saves the error to the database marked as not viewed. level - specify which function called this function.
type MockFullReader ¶
func NewMockFullReader ¶
func NewMockFullReader(sources map[string]string) *MockFullReader
func (*MockFullReader) Normalize ¶
func (self *MockFullReader) Normalize(name string) string
type OsFullReader ¶
type OsFullReader struct {
// contains filtered or unexported fields
}
func NewOsFullReader ¶
func NewOsFullReader() *OsFullReader
func (OsFullReader) Normalize ¶
func (self OsFullReader) Normalize(path string) string
func (*OsFullReader) SetBase ¶
func (self *OsFullReader) SetBase(path string)