config

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const FileName = "config.json"

FileName is the config file inside the data home.

Variables

View Source
var BotTokenRe = regexp.MustCompile(`^[0-9]{5,20}:[A-Za-z0-9_-]{30,}$`)

BotTokenRe matches a @BotFather token: numeric bot id, colon, secret.

Functions

func CommandName added in v0.1.1

func CommandName() string

CommandName is the shell command this instance was registered under. The installer's wrapper exports PAPERVALET_CMD; a bare binary falls back to its own file name.

func Home added in v0.1.1

func Home() (string, error)

Home returns the instance data directory: $PAPERVALET_HOME when set, otherwise ~/.papervalet. Every relative path the bot uses (session, db, plugins, data/, downloads/) lives under it.

Types

type BotConfig

type BotConfig struct {
	CommandPrefix   string   `json:"command_prefix"`
	CommandPrefixes []string `json:"command_prefixes,omitempty"`
	PluginsDir      string   `json:"plugins_dir"`
	PluginRepo      string   `json:"plugin_repo,omitempty"`
	OwnerID         int64    `json:"owner_id,omitempty"`
	MaxMessageLen   int      `json:"max_message_len,omitempty"`
	RateLimit       int      `json:"rate_limit,omitempty"`
}

type Config

type Config struct {
	Telegram TelegramConfig `json:"telegram"`
	Bot      BotConfig      `json:"bot"`
	Logger   LoggerConfig   `json:"logger"`
	I18n     I18nConfig     `json:"i18n"`
}

func Default added in v0.1.1

func Default() *Config

Default returns the config initialize writes for a fresh instance.

func Example

func Example() *Config

func Load

func Load(path string) (*Config, error)

func (*Config) GetPrefixes

func (c *Config) GetPrefixes() []string

GetPrefixes returns all configured command prefixes.

func (*Config) GetUpdateTimeout

func (c *Config) GetUpdateTimeout() time.Duration

func (*Config) Save

func (c *Config) Save(path string) error

Save writes the config atomically with owner-only permissions; it holds api_hash, so it must never be world-readable.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks if the config has required fields.

type ConfigError

type ConfigError struct {
	Errors []string
}

func (*ConfigError) Error

func (e *ConfigError) Error() string

type I18nConfig

type I18nConfig struct {
	DefaultLanguage string `json:"default_language"`
}

I18nConfig controls language behavior.

type LoggerConfig

type LoggerConfig struct {
	Level  string `json:"level"`
	Format string `json:"format"`
}

type TelegramConfig

type TelegramConfig struct {
	APIID       int    `json:"api_id"`
	APIHash     string `json:"api_hash"`
	SessionFile string `json:"session_file"`
	Database    string `json:"database_file"`
	// BotToken logs in the companion bot that hosts settings panels.
	BotToken       string `json:"bot_token"`
	BotSessionFile string `json:"bot_session_file,omitempty"`
}

Jump to

Keyboard shortcuts

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