options

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2023 License: GPL-3.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithAllowFromGroup

func WithAllowFromGroup(onlyFromGroup bool) func(*Options)

func WithAllowFromPrivate

func WithAllowFromPrivate(onlyFromPrivate bool) func(*Options)

func WithAutoRejectCall added in v1.2.0

func WithAutoRejectCall() func(*Options)

func WithCmdCacheTimeout

func WithCmdCacheTimeout(respCacheTimeout time.Duration) func(*Options)

func WithCommandLog

func WithCommandLog(cmdLog bool) func(*Options)

func WithDebugMessage added in v1.2.0

func WithDebugMessage() func(*Options)

func WithHistorySync added in v1.2.0

func WithHistorySync() func(*Options)

func WithHostNumber

func WithHostNumber(hostNumber string) func(*Options)

func WithLogLevel

func WithLogLevel(logLevel string) func(*Options)

func WithOSInfo added in v1.2.0

func WithOSInfo(osInfo string) func(*Options)

func WithOnlyFromSelf

func WithOnlyFromSelf(onlyFromSelf bool) func(*Options)

func WithPairCodeLogin

func WithPairCodeLogin() func(*Options)

func WithPostgresDSN

func WithPostgresDSN(pgDsn *PostgresDSN) func(*Options)

func WithScanQRLogin

func WithScanQRLogin() func(*Options)

func WithSendMsgTimeout

func WithSendMsgTimeout(sendMsgTimeout time.Duration) func(*Options)

func WithSqlDB

func WithSqlDB(sqlDB *sql.DB) func(*Options)

func WithSqliteFile

func WithSqliteFile(sqliteFile string) func(*Options)

func WithStoreMode

func WithStoreMode(storeMode string) func(*Options)

Types

type LoginOptions

type LoginOptions int8
const (
	SCAN_QR   LoginOptions = 0
	PAIR_CODE LoginOptions = 1
)

type Options

type Options struct {
	// HostNumber will use the first available device when null
	HostNumber string

	// StoreMode can be "postgres" or "sqlite"
	StoreMode string

	// LogLevel: "INFO", "ERROR", "WARN", "DEBUG"
	LogLevel string

	// This PostgresDsn Must add when StoreMode equal to "postgres"
	PostgresDsn *PostgresDSN

	// This SqliteFile Generate "ROXY.DB" when it null
	SqliteFile string

	// WithSqlDB wrap with sql.DB interface
	WithSqlDB *sql.DB

	WithCommandLog              bool
	CommandResponseCacheTimeout time.Duration
	SendMessageTimeout          time.Duration

	// OSInfo system name in client
	OSInfo string

	// LoginOptions constant of ScanQR or PairCode
	LoginOptions LoginOptions

	// HistorySync is used to synchronize message history
	HistorySync bool
	// AutoRejectCall allow to auto reject incoming calls
	AutoRejectCall bool

	// AllowFromPrivate allow messages from private
	AllowFromPrivate bool
	// AllowFromGroup allow message from groups
	AllowFromGroup bool
	// OnlyFromSelf allow only from self messages
	OnlyFromSelf bool
	// CommandSuggestion allow command suggestion
	CommandSuggestion bool
	// DebugMessage debug incoming message to console
	DebugMessage bool
}

func New

func New(options ...func(*Options)) (*Options, error)

func NewDefaultOptions

func NewDefaultOptions() *Options

func (*Options) Validate

func (o *Options) Validate() error

type PostgresDSN

type PostgresDSN struct {
	Host     string
	Username string
	Password string
	Database string
	Port     string
	SslMode  string
}

func NewPostgresDSN

func NewPostgresDSN() *PostgresDSN

func (*PostgresDSN) FromEnv

func (dsn *PostgresDSN) FromEnv() *PostgresDSN

func (*PostgresDSN) GenerateDSN

func (dsn *PostgresDSN) GenerateDSN() string

func (*PostgresDSN) SetDatabase

func (dsn *PostgresDSN) SetDatabase(database string) *PostgresDSN

func (*PostgresDSN) SetHost

func (dsn *PostgresDSN) SetHost(host string) *PostgresDSN

func (*PostgresDSN) SetMode

func (dsn *PostgresDSN) SetMode(sslMode string) *PostgresDSN

func (*PostgresDSN) SetPassword

func (dsn *PostgresDSN) SetPassword(password string) *PostgresDSN

func (*PostgresDSN) SetPort

func (dsn *PostgresDSN) SetPort(port string) *PostgresDSN

func (*PostgresDSN) SetUsername

func (dsn *PostgresDSN) SetUsername(userName string) *PostgresDSN

func (*PostgresDSN) Validate

func (dsn *PostgresDSN) Validate() error

Jump to

Keyboard shortcuts

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